以字节为单位测试C变量类型的大小

#include <stdio.h>

int main(void){
   printf( "/nA char      is %d bytes", sizeof( char ));
   printf( "/nAn int      is %d bytes", sizeof( int ));
   printf( "/nA short     is %d bytes", sizeof( short ));
   printf( "/nA long      is %d bytes", sizeof( long ));
   printf( "/nA long long is %d bytes/n", sizeof( long long));
   printf( "/nAn unsigned char  is %d bytes", sizeof( unsigned char ));
   printf( "/nAn unsigned int   is %d bytes", sizeof( unsigned int ));
   printf( "/nAn unsigned short is %d bytes", sizeof( unsigned short ));
   printf( "/nAn unsigned long  is %d bytes", sizeof( unsigned long ));
   printf( "/nAn unsigned long long is %d bytes/n",
                                 sizeof( unsigned long long));
   printf( "/nA float     is %d bytes", sizeof( float ));
   printf( "/nA double    is %d bytes", sizeof( double ));
   printf( "/nA long double is %d bytes/n", sizeof( long double ));


   return 0;
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266530.html

(0)
上一篇 2022年6月7日
下一篇 2022年6月7日

相关推荐

发表回复

登录后才能评论