I got a silly question...I actually came to this "problem" when looking at endianess.
I have the following test-code:
So. The value of "p" gets printed in hex:
FILE *out = fopen("test.txt", "w");
char test = "this is a test!\n";
int *p = malloc(sizeof(int));
memcpy(p, test, sizeof(int));
fwrite(p, 1, sizeof(int), out);
This would match: siht, so "this" spelled backwards. Its a little endian machine, so small-end stored first, therefore it's 73 ('s') that should be the biggest value and is printed first when interpreted as an integer.
But the following rest remains a riddle...
The code above also writes a file "test.txt" and stores the value of "p". Hexdump reveals:
But when reading the file "byte by byte" with "fgetc(...)" and output it hex I get:
0000000 6874 7369 -->matches "htsi"
which would match "this" again.
So there are 3 different forms now. Why ? I don't get it...
Anybody an idea?