Size of character ('a') in C/C++

前端 未结 4 1300
天命终不由人
天命终不由人 2020-11-22 03:08

What is the size of character in C and C++ ? As far as I know the size of char is 1 byte in both C and C++.

In C:

#include 

        
4条回答
  •  孤城傲影
    2020-11-22 03:25

    In C, the type of a character constant like 'a' is actually an int, with size of 4 (or some other implementation-dependent value). In C++, the type is char, with size of 1. This is one of many small differences between the two languages.

提交回复
热议问题