Thanks guys.
Salem, I might be wrong, but I think what you are saying is true only for complement to 2 representation.
"implementation defined" OK . Not very portable though.
Can I expect the physical representation of a specific non-ASCII character to be the same as an unsigned char and a char? Suppose I have ISO characters in the source file, will this work as expected:
Code:
char buf[21];
int j = 0;
for(; j < 20; j++){
int c = fgetc(pf);
if(c==EOF) {
break;
}
memset(&buf[j], c, 1); // c is the unsigned char value
}
buf[j] = '\0';
Say I write buf back to the file, will I get the same text? I think I will with my compiler, and probably with any reasoneable one. But it doesn't seem that the standard assures it, neither does it give any other way to do the unsigned char to char convertion while preserving the character that is being represented. I must have missed something here.
This is all for non ASCII (ISO-latin-1 in my case) characters of course