What happens here? sizeof(short_int_variable + char_variable)

前端 未结 5 1718
鱼传尺愫
鱼传尺愫 2020-12-03 22:03
#include 
 int main()        
{

           short int i = 20;

            char c = 97;

            printf(\"%d, %d, %d\\n\", sizeof(i), sizeof(c), s         


        
5条回答
  •  伪装坚强ぢ
    2020-12-03 23:08

    As others have told, sizeof is computed at compile-time.

    Here, value of the expression c + i integer, as c and i are promoted (integral promotion) to int and thus

    sizeof( c + i )
    

    gives you 4 bytes on 32-bit machine..

提交回复
热议问题