0
The following code snippet should show the entire value of the single character stored in the file. when I put a letter like 'a' for example works. but when I put this symbol: þ. and several others it shows -2 on the screen. this symbol according to the ASCII table has value 231. the code is this:
#include <stdio.h>
int main() {
FILE *ptr;
char c;
ptr = fopen("teste.txt", "r");
fscanf(ptr, "%c", &c);
printf("%d", c);
return 0;
}
the only thing stored in test.txt is the symbol þ.
The symbol þ seems not to have in the table ASCII, I read here with your code and the value that returned was -61. Which SO vc is using?
– gato
No, the ASCII table only goes up to code 127. You’re taking an extension of it. Then you can vary what returns. The character you are using is probably considered a character multibyte, That’s why you’re creating this mess. If you open the file in some software that allows you to read the file byte by byte, you will probably find 2 or more. There the file is reading only the first.
– Maniero
Got it, I’ll see that. My OS is Windows 7 professional
– Matheus
I advise reading of The Absolute Minimum That Every Software Developer Absolutely, Positively Needs to Know About Unicode AND Character Sets (No Excuses!)
– pmg
Take a look at this table http://ic.unicamp.br/~Everton/classes/hardware/tableASCII.pdf here you can see the character you want, but it is a little different.
– gato