I know this is a stupid question but I don't understand this problem. Could anyone please explain to me?
I know that a char is 1 byte. I created a file sample.txt and fill in "1234"
I used fseek and ftell to print the file size. The output is 4 bytes. This means each of char in the string "1234"
is 1 byte.
But when I write like this printf("%d", sizeof('4'));
The output is 4. So the char 4
is stored with 4 bytes.
So what are differences between the char 4
that read from the file and char 4
in the source?
*** My question was marked duplicated here: Why are C character literals ints instead of chars?
But it is not. The other topic doesn't explain why computer treats the char in the file as 1 byte each.