size of a datatype without using sizeof

后端 未结 21 2010
慢半拍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:04

    Well, I am an amateur..but I tried out this problem and I got the right answer without using sizeof. Hope this helps.. I am trying to find the size of an integer.

    int *a,*s, v=10;
    
    a=&v;
    
    s=a;
    
    a++;
    
    int intsize=(int)a-(int)s;
    
    printf("%d",intsize);
    

提交回复
热议问题