How do I write a file write loop?

Hello
I am trying to write a loop that lets me add an employee number with the data that the code gets from the user to a file. And then it runs the code again with different data and asks for a number again, and saves it in the same txt file. I only got as far as to write to a file, but nothing shows up in said file.The main program is done, its this part that I am having trouble with.
ofstream f;
f.open("filename", std::ofstream::app); //use the append flag!
f << "data"; //your data goes here.
f.close();

be aware that some IDE may not put the file where you think it should be. If it isnt working, put the full path on the file name and try it OR run the program from the command line and check the folder where you ran it for the file.
Last edited on
Thank you, I will try this tonight.
Topic archived. No new replies allowed.