NO

Author Topic: The answer does not match with the book (C Primer Plus)  (Read 5386 times)

twh_twh

  • Guest
#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

  • Guest
Re: The answer does not match with the book (C Primer Plus)
« Reply #1 on: May 22, 2012, 05:53:19 PM »
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...
« Last Edit: May 22, 2012, 05:55:20 PM by CommonTater »

twh_twh

  • Guest
Re: The answer does not match with the book (C Primer Plus)
« Reply #2 on: May 22, 2012, 07:13:21 PM »
warning #2223: Unable to convert character '\u00fe' to codepage 936; using default character.

why?

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: The answer does not match with the book (C Primer Plus)
« Reply #3 on: May 22, 2012, 11:34:25 PM »
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

  • Guest
Re: The answer does not match with the book (C Primer Plus)
« Reply #4 on: May 23, 2012, 03:16:17 AM »
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.





twh_twh

  • Guest
Re: The answer does not match with the book (C Primer Plus)
« Reply #5 on: May 23, 2012, 03:47:32 AM »
Thank you very much!!