post #1 of 1
Thread Starter 
Hey all, I have a final project due in approximately 14 hours... I have everything in my program working accordingly except for the part where it's asking for me to include a function for saving and loading to a file. I split the two processes apart and the saving to a file works perfectly how I set it up.

But my dilemma is loading. How do you pull integer values from a file through fstream?

This is what I've got so far:
Code:
void load_schedules(int jeff[][TIME], int anna[][TIME], ifstream& fin)
{
        int j = 0;
        
        fin.open("schedules.dat", ios::in);
        if(fin.fail())
        {
                cout << "Load File Open Error...";
                return;
        }
        
        cout << "Loading Jeff...\n";
        
        do
        {
                for(int i = 0; i <= 3; i++)
                {
                        fin >> jeff[i][j];
                }
        j++;
        }while(j <= 3);
        cout << "Jeff successfully loaded!\n";
        
        cout << "Loading Anna...\n";
        j = 0;
        do
        {
                for(int i = 0; i <= 3; i++)
                {
                        fin >> anna[i][j];
                }
        j++;
        }while(j <= 3);
        cout << "Anna successfully loaded!\n";
        
        fin.close();
        
        cout << "File successfully loaded!\n";
}

I threw in all those unnecessary couts in order to try and see where it's failing, but none of it comes out so I can't tell if it's an error in file opening or what.

Any help would be appreciated. smile.gif If any information's needed I'd be more than happy to throw it in.


EDIT: So I'm a big idiot and just realized that there's nothing wrong with the function and that in all actuality, I commented out the function call. Yay! Thanks for the views and I apologize for wasting the one minute of your life. biggrin.gif
Edited by Kaine - 12/13/11 at 8:00pm
Red Beast?
(15 items)
 
  
CPUMotherboardGraphicsRAM
i5-2500k 4.5GHz ASUS P8Z68-V PRO VisionTEK HD7970 2x4gb G.Skill ECO 1600mhz 
Hard DriveCoolingOSMonitor
Crucial C300 64Gb / Samsung F3 1TB Cooler Master Hyper 212+, Push/Pull Windows 7 Ultimate 64-bit IPS231P x 3, Eyefinity'd 
KeyboardPowerCaseMouse
Overclock.net Ducky MX Red XFX 850W Black Edition CoolerMaster HAF 932 Logitech G700 
Mouse PadAudio
Artisan SAMURAI HIEN Mid Small Asus Xonar DG 
  hide details  
Reply
Red Beast?
(15 items)
 
  
CPUMotherboardGraphicsRAM
i5-2500k 4.5GHz ASUS P8Z68-V PRO VisionTEK HD7970 2x4gb G.Skill ECO 1600mhz 
Hard DriveCoolingOSMonitor
Crucial C300 64Gb / Samsung F3 1TB Cooler Master Hyper 212+, Push/Pull Windows 7 Ultimate 64-bit IPS231P x 3, Eyefinity'd 
KeyboardPowerCaseMouse
Overclock.net Ducky MX Red XFX 850W Black Edition CoolerMaster HAF 932 Logitech G700 
Mouse PadAudio
Artisan SAMURAI HIEN Mid Small Asus Xonar DG 
  hide details  
Reply