| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Saving to file
im trying to save certain parts of my prgram to file.
i was wanting at the end to save. aname thats already in program and a score,id number and the date that this was saved to file. does anyone know how to do this?? oh and can you also tell me how to load in and display only what i have saved as well. |
|
#2
|
|||
|
|||
|
Yes you can write and read from a file easely...
Code:
#Include <fstream>
#include <iostream>
using namespace std;
char* read;
int main(){
fstream file_w("myfile.txt", ios::out);
file_w << "This is some text";
file_w.close();
fstream file_r("myfile.txt", ios::in);
file_r >> read;
cout << read << endl;
system("PAUSE");
file_r.close();
return 0;
}
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Saving to file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|