Monday, May 24, 2010

Load and save feature c++?

//load and save... i hope!!!


#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


using namespace std;


int main()


{


system ("color 2B");


int choice;


int number;





cout %26lt;%26lt; "hi.\n\n\nContinue:1\nNew:2\n\n\n";


cin %26gt;%26gt; choice;





if (choice==2)


{ cout %26lt;%26lt; "\n\nEnter number.";


cin %26gt;%26gt; number;





cout %26lt;%26lt; "Number stored";


}


if (choice==1)


{


cout %26lt;%26lt; "\n\n\nYour number is: ";


cout %26lt;%26lt; number;


}





system ("PAUSE");


return 0;


}





How do I make it to where when the user restarts the program it will display the number they entered before? everytime i try to load a number i entered it always says 49. plzz post

Load and save feature c++?
It seems like you aren't trying to store anything in an fstream at all even though you included it. Just initialize an fstream and write to the same place each time. The 49 you see is probably an uninitialized variable that happens to have a 49 in it. It will be something else later.

hibiscus

No comments:

Post a Comment