Convert char to int in C and C++

前端 未结 12 2135
梦毁少年i
梦毁少年i 2020-11-22 02:41

How do I convert a char to an int in C and C++?

12条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 03:12

    For char or short to int, you just need to assign the value.

    char ch = 16;
    int in = ch;
    

    Same to int64.

    long long lo = ch;
    

    All values will be 16.

提交回复
热议问题