I have a question about C++.
Assume
char timestamp[255];
char title[255];
etc..
and examples of the two strings:
Mon Oct 22 22:47:25 2001
My title
etc..
I want to save the data in a neat text file, and then read it in again.
I save the data by using:
fprintf (fp, "%s\n", timestamp);
fprintf (fp, "%s\n", title);
etc..
(I need the \n to have things presented properly in a text file)
and then I'm trying to read the data back by using:
fscanf (fp, "%s", timestamp);
fscanf (fp, "%s", title);
etc..
Because of the way the function fscanf works, it stops reading at the first space in either. I also don't want the /n character to be read as well, otherwise when I write all back again, extra empty lines are inserted in the text file.
I cannot find a trick to to it correctly. Can you help?
Regards,
Chaco van der Sijp
Assume
char timestamp[255];
char title[255];
etc..
and examples of the two strings:
Mon Oct 22 22:47:25 2001
My title
etc..
I want to save the data in a neat text file, and then read it in again.
I save the data by using:
fprintf (fp, "%s\n", timestamp);
fprintf (fp, "%s\n", title);
etc..
(I need the \n to have things presented properly in a text file)
and then I'm trying to read the data back by using:
fscanf (fp, "%s", timestamp);
fscanf (fp, "%s", title);
etc..
Because of the way the function fscanf works, it stops reading at the first space in either. I also don't want the /n character to be read as well, otherwise when I write all back again, extra empty lines are inserted in the text file.
I cannot find a trick to to it correctly. Can you help?
Regards,
Chaco van der Sijp