采用编译命令:
D:\mingw64\bin\gcc -m64 datatype.c -o datatype.exe
编译如下代码:
/**********
* C语言的数据类型
* 版本:0.1.0
* 开发人:沈波
* 完成时间:2021-4-8
* 版权所有,侵权必究
**********/
#include <stdio.h>
#include <sys/time.h>
#include <limits.h>
#include <stddef.h>
void main()
{
unsigned long int i,j;
/*运行时间测试框架*/
struct timeval timeStart, timeEnd;
/*运行时间测试框架 --------------- 运行起始时间*/
gettimeofday(&timeStart,NULL);
printf("Start time is: %lu.%lu \n\nYour program start run...\n\n", timeStart.tv_sec, timeStart.tv_usec);
/*在这里加入自己的程序*/
printf("char type size is %d byte. \n",sizeof(char));
printf("\tMax value is %d.\n\tMin value is %d.\n",CHAR_MAX,CHAR_MIN);
printf("unsigned char type size is %d byte. \n",sizeof(unsigned char));
printf("\tMax value is %d.\n",UCHAR_MAX);
printf("int type size is %d bytes. \n",sizeof(int));
printf("unsigned int type size is %d bytes. \n",sizeof(unsigned int));
printf("short type size is %d bytes. \n",sizeof(short));
printf("unsigned short type size is %d bytes. \n",sizeof(unsigned short));
printf("long type size is %d bytes. \n",sizeof(long));
printf("\tMax value is %ld.\n\tMin value is %ld.\n",LONG_MAX,LONG_MIN);
printf("unsigned long type size is %d bytes. \n",sizeof(unsigned long));
printf("float type size is %d bytes. \n",sizeof(float));
printf("double type size is %d bytes. \n",sizeof(double));
printf("long double type size is %d bytes. \n",sizeof(long double));
printf("size_t type size is %d bytes. \n",sizeof(size_t));
/*运行时间测试框架 --------------- 运行结束时间*/
gettimeofday(&timeEnd,NULL);
printf("\nEnd time is: %lu.%lu \n", timeEnd.tv_sec, timeEnd.tv_usec);
if (timeEnd.tv_usec-timeStart.tv_usec<0 )
{
printf("Time consuming is: %lu.%lu s\n", timeEnd.tv_sec-1-timeStart.tv_sec, 1000000+timeEnd.tv_usec-timeStart.tv_usec);
}
else
{
printf("Time consuming is: %lu.%lu s\n", timeEnd.tv_sec-timeStart.tv_sec, timeEnd.tv_usec-timeStart.tv_usec);
}
}
得到的datatype.exe程序,运行结果显示:
Start time is: 1618268775.890332
Your program start run...
char type size is 1 byte.
Max value is 127.
Min value is -128.
unsigned char type size is 1 byte.
Max value is 255.
int type size is 4 bytes.
unsigned int type size is 4 bytes.
short type size is 2 bytes.
unsigned short type size is 2 bytes.
long type size is 4 bytes.
Max value is 2147483647.
Min value is -2147483648.
unsigned long type size is 4 bytes.
float type size is 4 bytes.
double type size is 8 bytes.
long double type size is 16 bytes.
size_t type size is 8 bytes.
End time is: 1618268775.903324
Time consuming is: 0.12992 s
说明 long int依然是32位的,不是64位。这是怎么回事?