Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

character assignment

 
Geethakrishna Srihari
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain how assignment to character takes place:

char cf = '\101'; works fine....
what does it signify?

But char c = '\1001' ; gives compilation error.

if we assign unicode, why '\u00001' gives error even though it equals '\u0001'?
 
Erik Larson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'\101' is an octal representation of a number. The largest printable character is 255 decimal, or 377 octal. What is interesting is that if you assign the decimal value of '\1001' (513) to a char, that will print '?'. Why that is, I don't know. As for the unicode values, they must be exactly 4 hex digits.

'\101' == 0101 == '\u0041' == 0x41 == 65 == 'A'
[ May 25, 2005: Message edited by: Erik Larson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic