Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Hi all,
Ive been trying to retrieve two specific characters from a file and convert them to integers. I haven't been successful with a lot of different methods. Mostly Ive been trying to use ATOI without success. Any help? When I print out the value of REC2 of my code it just prints out a 1. //
char rec[2];
FILE *fp = fopen("/sd/mydir/trailer4.txt", "r");
fseek(fp,45,SEEK_SET); rec[0]=fgetc(fp); get a character/byte from the file
fseek(fp,46,SEEK_SET); rec[1]=fgetc(fp);
int rec2= atoi(rec);
fclose(fp);