Thread: Help with loading data.

  1. #1
    Registered User
    Join Date
    May 2004

    Help with loading data.

    ***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:
    int j = 0;
    ifstream CrashRecover;
    ofstream Coredump1;"C:\\coreDump.dat");"C:\\coreDump.dat");
                   cout<<"Welcome to the stack   
                   cout<<"Please enjoy yourself."<<endl;
    	int loop = 5;
    	cout<<"Now Recovering from Stack 
                         Overflow and System Crash....."<<endl;
    	while(loop != 0)
    	cout<<"Now don't do it again Hoser!!!"<<endl;
    Section to initiate restart error:
    if(Stackmanip.isItFull() == true)
    	cout<<"Warning!!!  Warning!!Warning!"<<endl;
    	cout<<"Stack Overflow."<<endl;
    	system("copy A:project3.exe c:\\");
    I have included the right header files. <cstdlib> <fstream>

    Thank you all.

  2. #2
    Registered User
    Join Date
    Jun 2003
    Just a question. Is this how the process works?...
    1) You run out of stack memory
    2) All that information is stored in a text file
    3) Your computer restarts
    4) All that information stored in a text file is brought back into the stack
    5) You run out of stack memory
    6) ...

    And now for something useful perhaps, could there be a problem with having the same file open twice at the same time for I/O?"C:\\coreDump.dat");"C:\\coreDump.dat");

  3. #3
    Registered User
    Join Date
    May 2004
    Yes to the first, and there shouldn't be a problem with using the same file for both variables. One is an input variable the other output. please inform me if I am wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. dynamically loading data?
    By elninio in forum C++ Programming
    Replies: 15
    Last Post: 07-28-2008, 12:46 AM
  3. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  4. C Programming Question
    By TK in forum A Brief History of
    Replies: 13
    Last Post: 07-04-2002, 07:11 PM
  5. Loading a struct with data from a file
    By TankCDR in forum C Programming
    Replies: 1
    Last Post: 10-28-2001, 08:58 AM