I'm trying to read a text file, 2k of dimension, form sd card, in ESDHC mode.
This is a part of my code:
void Schermata(char* percorso){
MQX_FILE_PTR fp;
unsigned char LOGO[2049];
fp=fopen(percorso,"r");
fscanf (fp, "%s", LOGO);
...
...
fclose(fp);
but in LOGO I find only the first 256 chars of the file.
Where is the mistake?
Many thanks and best regards,
Corrado
Hi,
I would say it is because of some 'safery' limitation of fscanf.
Imagine what will happen if someone will provide file bigger than 2K - fscanf have no way of knowing the size of buffer and your application will crash flat ...
Also "%s" stops reading on space ..., so if LOGO includes space it will only return first word from it.
I would use fread instead of fscanf ...
Regards,
Robert