Hey all, I was wondering could someone help me on writing a file to a notepad.exe file.

What i need help on is i have a gam and i want to record how many times the player 1 & 2 has won lost or had a draw.

How would i go about coding that? Also if one the players who played before was on how could i increase their score again?

char str[100]; 
ifstream f_myfile("test.txt");
// check that file opened OK 
if(!f_myfile) 
{ 
cout << "ERROR: can't open "; 
cout << "test.txt\n"; 
exit(1); 
}
// note use of the readahead structure 
f_myfile.getline(str, 100); 
while(!f_myfile.eof()) 
{ 
cout << str << "\n"; 
f_myfile.getline(str, 100); 
} 
f_myfile.close(); 
system("pause"); }

Thats what i got so far and that shows the file but i assume i need another bit of code for putting stuff in it?

Anyone able to help me plz?

anyone?, or can someone point me to an example? i've tried look for one but cant find any that does what i'm after.

You need to use fstream or ofstream to write to the file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.