***Warning this is for homework.
I am on the final debug for a program of mine. The program is designed to restart your computer upon going beyond the boundaries of your stack. The stack is an array based stack. When it restarts, the program saves the information in the stack to a file and when the computer starts again, it loads the data back into the stack.
The problem I am having is that although it saves the data, when it loads, the data is only a series of zeros. I thought of using ios::nocreate, but my program won't let me use it, saying that its invalid. The appropriate code follows.
Section to place data back into stack:
Code:
int j = 0;
ifstream CrashRecover;
ofstream Coredump1;
CrashRecover.open("C:\\coreDump.dat");
Coredump1.open("C:\\coreDump.dat");
if(!CrashRecover)
{
cout<<"Welcome to the stack
manipulator."<<endl;
cout<<"Please enjoy yourself."<<endl;
}
else
{
int loop = 5;
cout<<"Now Recovering from Stack
Overflow and System Crash....."<<endl;
Stackmanip.initialize();
CrashRecover>>j;
while(loop != 0)
{
Stackmanip.push(j);
CrashRecover>>j;
loop--;
}
cout<<"Now don't do it again Hoser!!!"<<endl;
Section to initiate restart error:
Code:
if(Stackmanip.isItFull() == true)
{
cout<<"Warning!!! Warning!!Warning!"<<endl;
cout<<"Stack Overflow."<<endl;
while(!Stackmanip.isItEmpty())
{
Stackmanip.popIt(popWhat);
Coredump1<<popWhat<<endl;
}
Coredump1<<endl;
system("copy A:project3.exe c:\\");
Stackmanip.restart();
}
I have included the right header files. <cstdlib> <fstream>
Thank you all.