c - Apostrophe in char data type -
c - Apostrophe in char data type -
char c; c = '2'; printf("%d\n",c);
so question quiz, asking display. reply 50, tried using program, why 50? not 2 or anything?
the apostrophes mean "character literal", i.e. '2' not integer 2, instead character 2, i.e. glyph used represent single digit 2.
you print value using %d in printf(), means "signed integer", integer value of character, called "code point" (or, classically, it's "ascii value").
i think code not 100% clean, since char might unsigned, should cast (int) in phone call clear, since int %d expects.
c arrays char structure apostrophe
Comments
Post a Comment