Reply To: Saving files

HomeForumsMonoBrick EV3 FirmwareSaving filesReply To: Saving files

#4441
Author Image
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); 
Posted in

Make a donation