C - Find the size of structure

后端 未结 7 1005
再見小時候
再見小時候 2021-02-10 01:43

I was asked this as interview question. Couldn\'t answer.

Write a C program to find size of structure without using the sizeof operator.

7条回答
  •  礼貌的吻别
    2021-02-10 02:02

    struct  ABC
    
    {
    
    int a;
    
    float b;
    
    char c;
    
    };
    
    
    void main()
    {
    
    struct ABC *ptr=(struct ABC *)0;
    
    ptr++;
    
    printf("Size of structure is: %d",*ptr);
    
    }
    

提交回复
热议问题