You have to use following syntax of fscanf to read particular characters.
int fscanf ( FILE * stream, const char * format, ... );
I have written following code to read particular characters using fscanf function. Just try to understand it.
Code:
#include <stdio.h>
int main ()
{
char strs [80];
float fs;
FILE * psFile;
psFile = fopen ("car.txt","w+");
fprintf (psFile, "%f %s", 3.1416, "PI");
rewind (psFile);
fscanf (psFile, "%f", &fs);
fscanf (psFile, "%s", strs);
fclose (psFile);
printf ("I have read: %f and %ss \ns",f,strs);
return 0;
}
Bookmarks