How to save data to file?

Started by
5 comments, last by murdoc 23 years ago
I''am converting one fileformat to other. And i use fwrite() for saving but it doesn''t work. Could you help me? Please!!!
Advertisement
Presuming you have a proper file handle. What errors do you get?
No errors!!! If i open file there is path for this file!
show us code...
how do u open... how do u write... do u close the file... etc.
Still not enough info, what doesnt work!

"There is humor in everything depending on which prespective you look from."
"There is humor in everything depending on which prespective you look from."
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 !
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

This topic is closed to new replies.

Advertisement