Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C file input

Name: Anonymous 2011-10-30 8:27

hey /prog/, i have a C problem

i am making a hang man game
everytime a session is launched, the player choses to play against a player (who inputs a word) or the computer (which selects words from a file)

the thing is, i want to write the words the player inputs inside of the string
if the string is already in the file, it's not added, if not it is added

so far i am able to write things in a file, but every time i start a new session, the new inputted text overwrite what was there before

i am using fopen("derp.txt", "r+");

Name: FrozenVoid 2011-10-30 8:52

http://www.cplusplus.com/reference/clibrary/cstdio/fopen/
"a+"    Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List