How to find the size of a variable without using sizeof

后端 未结 10 1747
终归单人心
终归单人心 2020-12-17 06:07

Let us assume I have declared the variable \'i\' of certain datatype (might be int, char, float or double) ...

NOTE: Simply consider that \'i\' is

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 06:38

    #include
    
    #include
    
    struct size1
    
    
      {
    int a;
    char b;
    float c;
    };
    
    void main()
    {
    struct size1 *sptr=0;  //declared one pointer to struct and initialise it to zero//
    sptr++;                 
    printf("size:%d\n",*sptr);
    getch();
    }
    

提交回复
热议问题