Home→Forums→MonoBrick EV3 Firmware→Saving files→Reply To: Saving files
June 20, 2014 at 07:38
#4441

Helmut Wunder
Participant
how is it possible to read/write variables other than bytes dircty,
without having to rearrange and convert data from basic bytes, e.g.
int16,
int32,
float64,
strings
arrays of single data type (e.g., arrays[6] of float)
structures
like fprintf, fscanf, and fputs etc. in C:
FILE * pFile;
int n;
char name [100];
pFile = fopen ("myfile.txt","w");
for (n=0 ; n<3 ; n++)
{
puts ("please, enter a name: ");
gets (name);
fprintf (pFile, "Name %d [%-10.10s]\n",n,name);
}
fclose (pFile);
//...
pFile = fopen ("myfile.txt","w+");
fprintf (pFile, "%f %s", 3.1416, "PI");
rewind (pFile);
fscanf (pFile, "%f", &f);
fscanf (pFile, "%s", str);
fclose (pFile);
printf ("I have read: %f and %s \n",f,str);
Follow