View Full Version: Saving Data

C++ Learning Community > C++ Help > Saving Data


Title: Saving Data
Description: ...guess


Shonoby - January 14, 2007 12:03 AM (GMT)
How do i save data in a specified file, then upload it and show the results of the saved data so it should be like so:
CODE

saving
{
group name;
room number;
teacher name;
month;
Male Absent #;
Male Half-Absent #;
Female Absent #;
Female Half-Absent #;
}
//[then]
loading
{
group name;
room number;
teacher name;
month;
Male Absent #;
Male Half-Absent #;
Female Absent #;
Female Half-Absent #;
}
//[then]
Display:
group name;
room number;
teacher name;
month;
Male Absent #;
Male Half-Absent #;
Female Absent #;
Female Half-Absent #;

This code is for the absentees in my school because i am in a EPIDEMIOLOGY group and i wanted to test my skill to see if i could make such a code, i alrdy made one but i need to make a new one that saves data.

Well, it should just save data then be able to display it once more, so does any1 know hot to do it or a link on how to do it???

Zaqufant - January 14, 2007 12:35 AM (GMT)
Basically, if you know how to do files you simply do somthing like this...
CODE
ifstream ifile;
ofstream ofile;
ofile.open("directory");

//now write the information like this
ofile << stuff << " ";//need a space so the information doesn't get mashed up with
//other data on the file a space or a new line ("\n")

//then close it
ofile.close();

//now open it agian
ifile.open("directory");

//now loop through it
ifile >> variable;
cout << variable;

It's somthing like that.

Shonoby - January 14, 2007 02:04 AM (GMT)
K thxz man,

Zaqufant - January 14, 2007 03:35 AM (GMT)
any time.
I did typed that kind of fast, so it's probably kind of wrong.

Shonoby - January 14, 2007 03:40 AM (GMT)
i know but i know about files so i fixed it up

Zaqufant - January 14, 2007 02:01 PM (GMT)
Cool.




Hosted for free by InvisionFree