Pointer arithmetic for structs

后端 未结 5 2232
鱼传尺愫
鱼传尺愫 2021-02-07 08:02

Given a struct definition that contains one double and three int variables (4 variables in all), if p is a pointer to this struct with a value 0x1000, what value does p++ have?<

5条回答
  •  南旧
    南旧 (楼主)
    2021-02-07 08:48

    p = p + sizeof(YourStruct)
    

    The compiler is free to decide what sizeof will return if you don't turn padding off.

提交回复
热议问题