Questions tagged «platform-independent»



3
与平台无关的size_t在c中的格式说明符?
我想打印出size_tC中类型的变量,但它似乎size_t是别名,它是不同体系结构上的不同变量类型。例如,在一台计算机(64位)上,以下代码不会引发任何警告: size_t size = 1; printf("the size is %ld", size); 但是在我的另一台计算机(32位)上,以上代码会产生以下警告消息: 警告:格式'%ld'期望类型为'long int *',但是参数3的类型为'size_t *' 我怀疑这是由于指针大小的差异所致,因此在我的64位计算机size_t上别名为long int("%ld"),而在我的32位计算机size_t上别名为另一种类型。 是否有专门用于格式的说明符size_t?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.