[I think the issue is more connected with fseek than fscanf..]
Hi!
Could anybody please explain me why this simple program to print the content of a file in a reverse order doens't work properly whit characters like 'è' or 'à' ecc...?
both fread and fscanf give the same problem: special chars are outputted like this: ��Code:#include <stdio.h>
int main ()
{
FILE *fPtr=fopen ("reverse1.txt","rb");
int ch,numBytes=0;
while ((ch=fgetc(fPtr))!=EOF)
numBytes++;
int i;
char c;
printf("\n****************\n");
for (i=0;i<numBytes;i++)
{
fseek (fPtr,-(i+1),SEEK_END);
fscanf(fPtr,"%c",&c);//fread (&c,sizeof(char),1,fPtr);
printf("%c",c);
}
printf("\n****************\n");
fclose (fPtr);
return 0;
}
Aren't they 1byte long like normal chars?
thanks!