Archived

This topic is now archived and is closed to further replies.

How to save data to file?

This topic is 6081 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

try thist example. you could you also fprintf.

void Write(void)
{

FILE * pFile;
char buffer2[8]="try this";
fwrite (buffer , 1 , 8 , pFile);
fclose (pFile);
}

Visit my web site www.web-discovery.net !

Share this post


Link to post
Share on other sites
3 problems I see right away

void Write(void)
{

FILE * pFile;
char buffer2[8]="try this"; // the buffer2 is too small it needs to be longer for the NULL char at the end of the string
// next you need to actually open the file and have a FILE pointer
// pfile = fopen(buffer2,"wt");

// what the hell is ''buffer'' What happened to ''buffer2'' ??
fwrite (buffer , 1 , 8 , pFile);
fclose (pFile);
}

You are just typing, not programming.
Find a book that covers the basics. I''ve programmed as a hobby for 3 or 4 years and I still use one.

ZoomBoy
Developing a iso-tile 2D RPG with skills, weapons, and adventure. See my old Hex-Tile RPG GAME, character editor, diary, 3D Art resources at Check out my web-site

Share this post


Link to post
Share on other sites