一、sizeof The return value of sizeof() is best saved with size_t. Under x86 and x64, this type has different representations, unsigned int (32 bits), unsigned __int64 (64-bit) #include <iostream> #include <string> #include <vector> int main() { int arrx[20]; auto n = _countof(arrx); //n = 20, the return value type is unsigned int. The macro _countf […]
Tag: offsetof
[C language] structure and offsetof implementation
Looking at the mountains from a distance, the water is silent. When spring is gone, flowers are still there, and birds are not surprised when people come. – Tang Dynasty·Wang Wei’s “Painting” In this blog, we will introduce the knowledge about structures in detail, which is full of dry goods. Structure declaration Generally speaking, a […]