Ask your own question, for FREE!
Computer Science 23 Online
OpenStudy (anonymous):

C++ trouble char c='8'

OpenStudy (anonymous):

calculate: c-'0'

OpenStudy (anonymous):

@ganeshie8 @quickstudent @emmigrace222 @ParthKohli @Abhisar @hartnn @cwrw238

OpenStudy (quickstudent):

Please don't ask me, I don't know anything about computer science.

hartnn (hartnn):

that will actually subtract 0 from 8, giving you 8 like if you do '8'-'2' output will be 6

OpenStudy (anonymous):

to expand a bit on @hartnn's answer: char c = '8' is actually 1 byte that, assuming ASCII character encoding, will have the value of 38 hex (or 00111000 in binary, you can consult http://www.asciitable.com/ for details). '0' has hexadecimal value of 30 (or binary 00110000). Now if you do 38h - 30h you will get 8h. Going back to our ASCII table that is the character that represents that backspace. Hope this helps :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!