0

just a curious question

why did o appeared as the output why not h? I know that a character variable can store only a single character even though why did the last character appeared and not the first character. http://www.sololearn.com/app/cplusplus/playground/c2Faf5lbA32Y/

19th Jul 2016, 5:58 AM
Infinity
Infinity - avatar
1 Resposta
0
Even though cin will let you enter multiple characters, a char will only hold 1 character. Consequently, only the first input character is placed in ch. The rest of the user input is left in the input buffer that cin uses, and can be accessed with subsequent calls to cin, creating bugs in your software. Check the CharTest code as an example.
19th Jul 2016, 10:10 AM
Tomcat
Tomcat - avatar