C++ character to int

前端 未结 5 1712
梦谈多话
梦谈多话 2020-12-11 16:36

what happens when you cin>> letter to int variable? I tried simple code to add 2 int numbers, first read them, than add them. But when I enter letter, it just fails and prin

5条回答
  •  一个人的身影
    2020-12-11 17:01

    if you explicitly cast your char to an int, it'll use the ASCII code, else it's not doing the cast by itself to int, so you get the strange results you are getting.

提交回复
热议问题