mitrmkar 1,056 Posting Virtuoso

You might compile the SDL from source hence having complete control over the run-time library usage. You should not use a mixed combination of the libraries (i.e. static/dynamic/debug/release ...).

mitrmkar 1,056 Posting Virtuoso

/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MD /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt

Since you are doing a debug build, the "/MD" -option does not match. Open:

Project/Properties/Configuration Properties/C/C++/Code Generation

and change the option "Runtime Library" to:

"Multi-threaded Debug DLL (/MDd)"

mitrmkar 1,056 Posting Virtuoso

It is some sort of project configuration mismatch, you could post the complete command line of the compiler. Try looking in Project/Properties/Configuration Properties/C/C++/Command Line.

mitrmkar 1,056 Posting Virtuoso

What is causing this difference in speed? :icon_rolleyes:

You might be interested in the amount of memory de/allocation operations that occur during the tests. Gathering basic statistics on malloc/free/realloc calls is quite simple by means of _CrtSetAllocHook(), see
http://msdn.microsoft.com/en-us/library/820k4tb8(VS.80).aspx

mitrmkar 1,056 Posting Virtuoso

Im really not sure why but it doesn't hide the window, i checked everything i could see but i think i've still done something wrong.
any ideas? :(

Use the STARTF_USESHOWWINDOW flag ...

PROCESS_INFORMATION info;
	STARTUPINFO startup;
	memset(&startup, 0, sizeof(startup)) ;
	memset(&info, 0, sizeof(info)) ;
	startup.cb = sizeof(startup);
	startup.wShowWindow = SW_HIDE;
        [B]startup.dwFlags |= STARTF_USESHOWWINDOW;[/B]
        // ...
mitrmkar 1,056 Posting Virtuoso

can u write the whole code for me once...plz... and you can use inheritance and arrayas well plz use the easiest way and reply as soon as possile

I think that will not happen, see here
http://www.daniweb.com/forums/announcement8-2.html

If you post your effort (the code you've done this far), then you'll probably get help with it. If you post it, try explaining/pin-pointing the difficulties you have with it.

mitrmkar 1,056 Posting Virtuoso

YOUR_DLG_HWND means the window handle (HWND) of your dialog. If you are using MFC, the handle is m_hWnd member of the CDialog class.

mitrmkar 1,056 Posting Virtuoso

If I understood the question correctly, then you need to add the following in your WM_INITDIALOG handler ... ModifyStyle(YOUR_DLG_HWND, 0, WS_SYSMENU|WS_MINIMIZEBOX, 0);

mitrmkar 1,056 Posting Virtuoso

Then i receive a "properties.exe has encountered a problem and needs to close. We are sorry for the inconvenience." Windows error message.

Appears as if lpszString would be NULL, so try adding a check against that condition ...

BOOL CALLBACK PropEnumProcEx(HWND hwnd, LPTSTR lpszString, HANDLE hData, ULONG_PTR dwData) {

  LPTSTR pszPropLabel = lpszString ? lpszString : "not available";
 
  cout << "Property Label: " << pszPropLabel << "." << endl;
  return true;
}
mitrmkar 1,056 Posting Virtuoso

I wish I could find my old code.

Somewhat off topic, but anyway, I think you might benefit from having your code under version control, here is one pointer to get you started with it ...
http://subversion.tigris.org/

mitrmkar 1,056 Posting Virtuoso

You might use seekg() along with tellg(), see here for an example
http://www.cplusplus.com/reference/iostream/istream/tellg.html

mitrmkar 1,056 Posting Virtuoso

The following should work ...

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
for ( int i = 0; i < checkedListBox1->CheckedItems->Count; i++ )
{
    listBox1->Items->Add
    (
	checkedListBox1->[B]GetItemText[/B](checkedListBox1->CheckedItems[i])
    );
}
mitrmkar 1,056 Posting Virtuoso

Move the two lines to a .cpp file, now they seem to be in a header file.

I.e. these two lines ...

nodePtr head=NULL;
nodePtr current=head;
mitrmkar 1,056 Posting Virtuoso

but with this i am getting linker errors

There are quite many linker errors, which errors are you receiving?

mitrmkar 1,056 Posting Virtuoso

You simply need to initialize the pointers ...

nodePtr head = 0;
nodePtr current = 0;

The extern declarations of the pointers you have there, do not impact the actual variables' values in any way, in case you were expecting that to happen.

mitrmkar 1,056 Posting Virtuoso

The value of 'x' is invalid subscript at the point where the error occurs, it exceeds the size of Store2.

You are using uninitialized variables (x, a) there, it's a bad practice.

void Write_Data(vector <Weather> Data) {
  
  double count, y, z, angle1, angle2, count2;  
  int x, a, b; 
[B]  // what might be the value of 'a' at this point?[/B]
  cout << "a is initially: " << a << '\n';

  Found Temp;
  Found2 Temp2;
  vector <Found> Store;
  vector <Found2> Store2;
  
  count2 =0;
  
    for (b=0; a<Data.size(); a++) {
      Temp2.height =0;
	  Temp2.VMDsea =0;
	  Temp2.VMDswell =0;
	  Temp2.yes=0;
	  Store2.push_back(Temp2);
	}//for statement

 [B]   // how many entries were added to Store2 ...[/B]
    cout << "Store2 size: " << Store2.size() << '\n';
...

Then you have ...

if (angle1=0 && Data[x].Hs <= y)
	    count2 = count2+1;

Did you mean comparison instead?

if (angle1==0 && Data[x].Hs <= y)
	    count2 = count2+1;

Note that in Data[x].Hs above, x is also uninitialized but doesn't trigger any error due to the malformed if condition ...

So revise your code and check how it behaves after that ...

mitrmkar 1,056 Posting Virtuoso

What is the difference by using 'private' and 'public' in derived class.
Eg:
class DistSign:public Distance and class DistSign:private Distance

See here
http://www.parashift.com/c++-faq-lite/private-inheritance.html

mitrmkar 1,056 Posting Virtuoso

Maybe I am just being dumb in this situation, but wouldn't there then need to be spaces like so:

109884 , 109278 , 1078508

No need for spaces, although there can be tabs/spaces, but those will be ignored. It will work as long as there is a separating comma (or any other character that cannot be taken as part of value, for that matter).

mitrmkar 1,056 Posting Virtuoso

The following might work for you, assuming that the values are always comma-separated

string line;
	double x,y,z;
	char dummy; // for skipping commas

	while ( getline(canopyfile, line) )
	{
		stringstream iss(line);

		if(iss >> x >> dummy >> y >> dummy >> z)
		{
			holder.setx(x);
			holder.sety(y);
			holder.setz(z);

			canopyvec.push_back(holder);
		}
		else
		{
			// failed to extract 3 values
		}
	}
cbattagler commented: Thank you again +1
mitrmkar 1,056 Posting Virtuoso

However I wonder why it goes up to 130 MB, that is a lot more than perheps it should be about 70 MB instead.

Every std::string object that you push onto a vector has its own overhead. You can check in code what sizeof(std::string) gives to be the size of a string. That much overhead will be used for each string you store in a vector.
When you have loaded all the data, sum together the vectors' sizes (i.e. the number of strings you have stored) hence you will know how much 'extra' memory you are using.

When you call vector.clear(), the objects contained will be dropped and their destructor will be invoked i.e. the memory will be released.

mitrmkar 1,056 Posting Virtuoso

How make in MFC C++:
i need a function, the function has read a txt file and put a message box with text which is in txt file.

Below is one way of doing it

void some_function()
{
    CStdioFile File;
    CString strLine;
    CString strMsg;

    if(File.Open("file.txt", CFile::modeRead))
    {
        while(File.ReadString(strLine))
        {
            strMsg += strLine + '\n';
        }
    }

    AfxMessageBox(strMsg, MB_ICONINFORMATION);
}
mitrmkar 1,056 Posting Virtuoso

Right... I thought it might be something like that....

So basically when I pass a char array to a function that takes a pointer, I'm taking the address of the array, which goes out of scope at the end of the if block. If I were to use a string, I would be copying the actual data to a new memory location, not just copying the memory location, right? Now, if I did that, would I need to change the data type of m_nextRoomScript to string, or would there be a way to still keep that as a char*?

I think you've understood it now. I'm guessing that you desire to have the char* in order for to write the data to a file or compare it (using strcmp())... you can very well use a std::string and wherever you need a const char * to the data held by the std::string, you can use the std::string' c_str() function which returns a const C-style string.

Trying to make this clearer ...

void function()
{
    char regular_arr[20]= "abc";
    std::string std_string = regular_arr; // copies the 'abc' into the string

    if(0 == strcmp(regular_arr, std_string.c_str()))
    {
        // the stríngs are identical, do something ...
    }

    FILE * fp = fopen("a.txt", "w");

    if(fp)
    {
        // write the string to file
        fputs(std_string.c_str(), fp);
    }
}
mitrmkar 1,056 Posting Virtuoso

The buffer next_room_script[] lives in the scope of the containing if() block. Your problem will go away if you change the m_nextRoomScript to be a std::string because the string will copy and hold the data you have read from the file. The pointer version just points to the temporary buffer and gets garbled.

mitrmkar 1,056 Posting Virtuoso

Related to posting ...

In case you haven't noticed, there is also a "Preview Post" button available. Press that button and you'll see a preview of how your post will look like. It does not submit your post, it just displays the preview.

mitrmkar 1,056 Posting Virtuoso

In the zedGraph control you can change BackColor and also choose a BackgroundImage but none of these 2 oppurtunities does anything to the ZedGraph-Control.

I suggest you post strictly ZedGraph related questions to the dedicated help forum in
http://sourceforge.net/forum/forum.php?forum_id=392232

mitrmkar 1,056 Posting Virtuoso

but i dont know where to start..i have tried comparing strings but i get stuck on how the loop should ignore the string "hello 33"

Ignoring the string is the same as not writing it to the output file at all.

Like Salem stated:

Now in the while loop you
- write the line unchanged
- write a different line
- don't write the line at all.

mitrmkar 1,056 Posting Virtuoso

tell what should i do and how ????

I think you should study from the very beginnings of C++. See
http://www.cprogramming.com/tutorial.html#c++tutorial
for a beginner's tutorial, especially pay attention to topics you need "if , case , while , switch, functions".
Take your time to go through it, and maybe post questions regarding the things you cannot figure out.

mitrmkar 1,056 Posting Virtuoso

If you have the BGI documentation, then go through it, and learn how the functions you are using (all of them) indicate an error condition of any kind. If you don't have it, then you might want to take look in
http://www.cs.colorado.edu/~main/cs1300/doc/bgi/ to have an idea of how the BGI works.

Then add code that checks for any error(s) that might have occurred. This way you may find out the root cause.

mitrmkar 1,056 Posting Virtuoso

I can't do that. I have to define it in the header file or else I get this error:

You need to #include the respective header file in interpotcntrlparams.cpp.

mitrmkar 1,056 Posting Virtuoso

Move the definition of QStringList FuncCntrlParams::type_pairPotList into the respective .cpp file.

mitrmkar 1,056 Posting Virtuoso

Add e.g. a Reset() member function in which you reset the member variables to desired values.

mitrmkar 1,056 Posting Virtuoso

Hey
I made this function i think it'll do the job. But i keep getting an expected declaration before "}". What do you guys think?

Hi,

First of all, I repeat what VernonDozier already stated;

Use code tags and formatting please:
see here
http://www.daniweb.com/forums/misc-explaincode.html

Then about the errors ...

bool readStudents(string fName, studentType stuList[], int& size)
{

   ifstream inFile;
   studentType stu;
   size = 0;

   inFile.open (fName.c_str()); 
  
    if (inFile.is_open())
    {
      inFile >> stu.id >> stu.assignments[0] >> stu.exam >> stu.total;
      while(inFile)
      {
        size++;
        cout << stu.id << ' ' << stu.assignments[0] << ", " << stu.exam << ' ' << stu.total << endl;
        inFile >> stu.id >> stu.assignments[0] >> stu.exam >> stu.total;
      }
      return true;
    }
    else
     return false;
    // the close() function takes no parameters,
    // the name of the file is already known by the ifstream object,
    // so just simply ...
    inFile.close ();
}
} // <- This brace must be removed
mitrmkar 1,056 Posting Virtuoso

Seems that a static function has to be defined in the class itself and not outside the class.

That is not true, you really can define the static member function outside the class. Maybe you've applied the 'static' keyword also to the definition of the static member function.

Anyhow, for the sake of clarity, the following setup should compile without a glitch.

your main .cpp file

#include "date.h"
int main()
{
    Date::set_default(9,7,2000);
    Date S(3,7,1991);
    S.addyear(18);

    return 0;
}

your date.cpp file

#include "date.h"
Date Date::default_date(9,7,2000);
const Date Date::default_date_const(9,7,2000);

Date::Date(int dd=0,int mm=0,int yy=0)
{
	d=dd? dd:default_date.d;
	m=mm? mm:default_date.m;
	y=yy? yy:default_date.y;
}

Date& Date::addyear(int n)
{
    y +=n;
    return *this;
}

void Date::set_default(int dd,int mm,int yy)
{
    Date::default_date.d=dd;
    Date::default_date.m=mm;
    Date::default_date.y=yy;
}

your date.h file

#ifndef DATE_H_DEFINED
#define DATE_H_DEFINED

class Date
{
	static Date default_date;
	static const Date default_date_const;
	int d,m,y;        
public:		
	static void set_default(int dd,int mm,int yy);
	Date(int,int,int);
	Date& addyear(int);
	int show_date(){return d;}
	int show_month(){return m;}
	int show_year(){return y;}
};
#endif // #ifndef DATE_H_DEFINED
mitrmkar 1,056 Posting Virtuoso

1) To make the call Date::set_default(), needs the set_default() to be a static member function.
2) It is not enough to declare a static member variable inside the class declaration, you also need to define and optionally initialize it.

class Date
{
    // a non-const default date
    static Date default_date;

    // a const default date
    static const Date default_date_const;

    int d,m,y;        

public:
    static void set_default(int dd,int mm,int yy);
    Date(int,int,int);
	
    <snip>
}; // class Date ends here

// the non-const default date defined & initialized here
Date Date::default_date(9,7,2000);
// the const default date defined & initialized here
const Date Date::default_date_const(9,7,2000);

int main()
{
    // Date::set_default() is now a static member function,
    //  so the following call works
    Date::set_default(9,7,2000);
    Date S(3,7,1991);
    cout<<"Date"<<S.show_date()<<"-"<<S.show_month()<<"-"<<S.show_year()<<"\n";
    S.addyear(18);
    cout<<"Date"<<S.show_date()<<"-"<<S.show_month()<<"-"<<S.show_year();
    return 0;
}
Nick Evan commented: thanks for the correction +5
mitrmkar 1,056 Posting Virtuoso

Well, the above didnt work. To look at that output see attachment.

Sorry, but I'll have to give up on that one then.

And anyway latest Borland C++ compilers dont support BGI graphics.

About upgrading your compiler, the main point is that you should give up on an antique compiler in case you are into modern computing.

The program could be written only in Turbo C++ 3.0.

I actually tried that one on Dev-C++ with Winbgi library and it worked for me :).

mitrmkar 1,056 Posting Virtuoso

However I cant find "ZedGraphControl" anywhere to drag and drop this control.

Open Tools/Choose Toolbox Items/.NET Framework Components
Click Browse and select the component .dll. Click OK and the ZedGraphControl should appear in the Toolbox.

mitrmkar 1,056 Posting Virtuoso

If your intention is to convert a string of digits to a long value, then see the strtol() function
http://www.cplusplus.com/reference/clibrary/cstdlib/strtol.html

mitrmkar 1,056 Posting Virtuoso

The part that I am stuck at: http://img60.imageshack.us/img60/993...webhelpqj4.jpg

You have to select the correct list from the "Show directories for:" list
Then click the yellow folder image to add a new entry to the list and enter the path.

<SDKPath>\Include directory goes into the "Include files" list and
<SDKPath>\Lib into the "Library files" list and
<SDKPath>\Bin into the "Executable files" list.

mitrmkar 1,056 Posting Virtuoso

Nope, it doesnt work, instead some of the text's pixels are coming in the borders of the rectangle, i.e it looks corrupted on its sides only.

Hmm, sorry but I don't fully understand that one. Perhaps you could try the following ...

void boxout(int xstart,int xend,int ystart,int yend,char item[])
{
  moveto(xstart,ystart);
  
  setcolor(LIGHTGRAY);  
  setfillstyle(SOLID_FILL,LIGHTGRAY);
  rectangle(xstart,ystart,xend,yend);
  floodfill(xstart+1,ystart+1,LIGHTGRAY);

  // at this point you should have a filled LIGHTGRAY rect

  for(int i=xstart;i<=xend;i++)
   {
    putpixel(i,ystart,WHITE);
    putpixel(i,yend,DARKGRAY);
   }

  for(int i=ystart;i<=yend;i++)
   {
    putpixel(xstart,i,WHITE);
    putpixel(xend,i,DARKGRAY);
   }

  // lastly, output the text
  setbkcolor(LIGHTGRAY);
  setcolor(BLACK);
  outtext(item); 
}

Then lastly, I think you really should consider getting yourself a newer development system, like MS VC 200x Express / Borland C++ Builder, which are available for free.

mitrmkar 1,056 Posting Virtuoso

I tried many times but all in vain. Error...error.. and not even compiled.

One practical approach, to get you started, would be to post the code that is not compiling (along with the error message(s)).

mitrmkar 1,056 Posting Virtuoso

A .PDF reader / outperforms Adobe's Reader big time (free)
Foxit Reader
www.foxitsoftware.com

A collection of Windows troubleshooting/monitoring tools (free)
Sysinternals Suite
http://technet.microsoft.com/en-us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx

mitrmkar 1,056 Posting Virtuoso

This is simple to fix ... relax

Employee employee1(); // <- actually declares a function returning an Employee
// instead use ...
Employee employee1;

If the Employee's constructor would take argument(s), then you could have it like

string FirstName, LastName;
Employee employee1(FirstName, LastName);

Regarding code tags, the ending tag is [/code].

mitrmkar 1,056 Posting Virtuoso

Try relocating the outtext(item) call ...

void boxout(int xstart,int xend,int ystart,int yend,char item[])
 {
  setcolor(BLACK);
  moveto(xstart,ystart);

  setcolor(LIGHTGRAY);
  setfillstyle(SOLID_FILL,LIGHTGRAY);
  rectangle(xstart,ystart,xend,yend);
  floodfill(xstart+1,ystart+1,LIGHTGRAY);

  for(int i=xstart;i<=xend;i++)
   {
    putpixel(i,ystart,WHITE);
    putpixel(i,yend,DARKGRAY);
   }

  for(i=ystart;i<=yend;i++)
   {
    putpixel(xstart,i,WHITE);
    putpixel(xend,i,DARKGRAY);
   }

  outtext(item);
  }
mitrmkar 1,056 Posting Virtuoso

Also, is there a way to check if the end of a file has been reached with ifstream? Because I'm using feof() in my program.

see
http://www.cplusplus.com/reference/iostream/ios/eof.html

mitrmkar 1,056 Posting Virtuoso

This is not something I can use in VC++ 2008 .NET Express Edition, I beleive ?

I think there should be no problems with VC++ 2008 .NET Express. Give it a try by opening the ZedGraphSampleVC.sln (the VC ++ sample) and see how it works. The class library's code comes precompiled in the ZedGraph.dll (a dynamic link library) - so you need to add that file as a reference in your VC++ projects that use the ZedGraph. In the sample project this reference already exists (see Project/Properties/Common Properties/References).

The documentation for the library is available here
http://zedgraph.sourceforge.net/documentation/default.html

and then there is a dedicated user forum in here (seems to be quite active)
http://sourceforge.net/forum/forum.php?forum_id=392232

mitrmkar 1,056 Posting Virtuoso

You must take care to use operator 'delete' only on objects that have been allocated using operator 'new', without any exceptions.

If you look into your code, you will see that this is NOT happening.
In the checkOutVideo() function you have; RentedVideo newRentedVideo(avblVideo->getVideoTitle() ...); i.e. the newRentedVideo object has not been allocated using new, instead it lives on stack only, and in the RentedVideo() constructor you assign the class' static pointer to this stack object. And later on, via checkInVideo() you eventually use the delete operator on that address, that is where the damage (silently in this case) occurs.

So you need to check all the code that it behaves well with regard to new/delete.

Maybe your allocation and deallocation of Customer and AvailableVideo classes is OK, I'm assuming here that you allocate those objects using new, since you load the data from file.

mitrmkar 1,056 Posting Virtuoso

Excel 2003 has both LOG() & LOG10(), why would the LOG() in spreadsheet be log10() in C?

Unable to answer that one, but just for reference:

Compute natural logarithm / log()
http://www.cplusplus.com/reference/clibrary/cmath/log.html

Compute base-10 logarithm / log10()
http://www.cplusplus.com/reference/clibrary/cmath/log10.html

mitrmkar 1,056 Posting Virtuoso

The end condition for the loop where you iterate over the list might be wrong or your list is not terminated properly (or something else).

If you've been wondering about this for a week now, it is probably better to post code that is relevant to the problem.

mitrmkar 1,056 Posting Virtuoso

You might find ZedGraph useful, it's a class library written in C#.

The project's web site is here
http://zedgraph.org/wiki/index.php?title=Main_Page

And some sample projects can be downloaded here
http://sourceforge.net/project/downloading.php?group_id=114675&use_mirror=heanet&filename=zedgraph_sample_projects_5.1.2.zip&83843110&testing=1

mitrmkar 1,056 Posting Virtuoso

I think you might be missing the point 'The latter being trivially true all the time.' i.e. you have to write the if statement like: if (f == 1 || f == 3) If you write it like:

if (f == 1||3)
// or
if (f == 1 || 3 != 0 )

then the condition will always be true, regardless of the f's value, because 3 simply is not equal to 0.