Is the size of C “int” 2 bytes or 4 bytes?

后端 未结 13 2754
不知归路
不知归路 2020-11-22 10:52

Does an Integer variable in C occupy 2 bytes or 4 bytes? What are the factors that it depends on?

Most of the textbooks say integer variables occupy 2 bytes. But whe

13条回答
  •  礼貌的吻别
    2020-11-22 11:12

    #include 
    
    int main(void) {
        printf("size of int: %d", (int)sizeof(int));
        return 0;
    }
    

    This returns 4, but it's probably machine dependant.

提交回复
热议问题