Archived

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

murdoc

How to save data to file?

Recommended Posts

I''am converting one fileformat to other. And i use fwrite() for saving but it doesn''t work. Could you help me? Please!!!

Share this post


Link to post
Share on other sites
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