size of a datatype without using sizeof

后端 未结 21 1966
慢半拍i
慢半拍i 2020-12-01 02:34

I have a data type, say X, and I want to know its size without declaring a variable or pointer of that type and of course without using sizeof oper

21条回答
  •  渐次进展
    2020-12-01 03:03

    #include  
    
    using namespace std; 
    
    int main() 
    { 
    
        // take any datatype hear 
        char *a = 0; // output: 1
    
        int  *b = 0;  // output: 4
    
        long *c = 0; // output: 8
    
        a++;
    
        b++;
    
        c++;
    
        printf("%d",a);
    
        printf("%d",b);
    
        printf("%d",c);
    
        return 0; 
    }
    

提交回复
热议问题