I have a file archivo3.txt
with "ABCDEFGHI", I read the 3 first characters though fgetc
SEPARATELY (differents printf
) and works properly (41, 42, 43 are displyaed), the problem comes when I try to do the same but using only one printf
.
In that case the values are displayed from rigth to left (43,42,41). Does anybody know what happens?
My code is:
#include<stdio.h>
#include<stdlib.h>
int main(){
FILE*app_f=fopen("archivo3.txt", "rb");
if(app_f==NULL){
printf("error al abrir el archivo");
exit(1);
}else{
fseek(app_f,0, SEEK_SET);
printf("caracteres %02X\n", fgetc(app_f));
printf("caracteres %02X\n", fgetc(app_f));
printf("caracteres %02X\n", fgetc(app_f));
printf("\n--------------\n");
fseek(app_f,0, SEEK_SET);
printf("caracter %02X, %02X, %02X\n", fgetc(app_f), fgetc(app_f), fgetc(app_f));
}
return 0;
}