anita177
asked on
Saving structures to files
Helloo..
I'm doing a project and i have assigned various values to structure members in my main program.. i wanted to know how i could transfer the data values from the structure into a text file for read and write operations.
In the main program the data is read in to the structure using an array.. so i want to pass the value each time to the seperate file before the end of the loop is reached...
I hope this makes sense and you can help!!!
I'm doing a project and i have assigned various values to structure members in my main program.. i wanted to know how i could transfer the data values from the structure into a text file for read and write operations.
In the main program the data is read in to the structure using an array.. so i want to pass the value each time to the seperate file before the end of the loop is reached...
I hope this makes sense and you can help!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok....
I've read the d
I've read the d
Huh? Is there a problem?
Why the low grade??
struct Data
{
int i;
double d;
char c[10];
};
you would write the file like
fstream Fil("C:\\SOMENAME.TXT",ios
Data D = ????;
Fil << D.i << ' ' << D.d << ' ' << D.c << endl;
Then you could read it like
fstream Fil("C:\SOMEFILE.TXT,ios::
Data D;
Fil >> D.i >> D.d >> D.c;
Let me know if you have any questions. (I'll probably need more details from you though.)