The answer does not match with the book (C Primer Plus)

Started by twh_twh, May 22, 2012, 05:20:07 PM

Previous topic - Next topic

twh_twh

#include <stdio.h>
int main(void)
{
  unsigned char a;
  char b;
  a = '\376';
  b = a;
  printf("%d,%d",a,b);
  return 0;
}
The answer is the book :254,-2
In pelles c:63,63 why?

CommonTater

You should not post stuff like this as a bug report... Pelle is way too busy to ask him to weed through this kind of problem.

Look in your project options on the compiler tab... is "Char type is unsigned" checked? 
If so uncheck it; your b variable is a signed character.

For what it's worth...

twh_twh

warning #2223: Unable to convert character '\u00fe' to codepage 936; using default character.

why?

Stefan Pendl

The problem here seems to be the regional settings of your system, which seem to be for an Asian language.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

For what it's worth...  http://msdn.microsoft.com/en-US/goglobal/cc305153

Apparently \376 = 0xFe = 254, doesn't map to any character on that code page.