Have a look at this page :
fgets - C++ Reference[
^]. It has sample code that opens a file, reads a line, and closes the file. There is a link in the "see also" section to fputs and that writes a line to a file. That should be enough to get you started.