C语言 | 32位机 | 64位机 |
---|---|---|
char | 1字节 | 1字节 |
short int | 2字节 | 2字节 |
int | 4字节 | 4字节 |
long int | 4字节 | 4字节 |
long long int | 8字节 | 8字节 |
float | 4字节 | 4字节 |
double | 8字节 | 8字节 |
指针( * ) | 4字节 | 8字节 |
(以上基于dev32位以及64位测试)
32位测试代码:
#include<stdio.h>
int main(){
printf("32位:\n");
printf("char :%d\n",sizeof(char));
printf("char* :%d\n",sizeof(char *));
printf("short :%d\n",sizeof(short));
printf("short *:%d\n",sizeof(short *));
printf("int :%d\n",sizeof(int));
printf("int * :%d\n",sizeof(int *));
printf("long int :%d\n",sizeof(long int));
printf("long int * :%d\n",sizeof(long int *));
printf("long long int :%d\n",sizeof(long long int));
printf("long long int * :%d\n",sizeof(long long int *));
printf("float :%d\n",sizeof(float));
printf("float * :%d\n",sizeof(float *));
printf("double :%d\n",sizeof(double));
printf("double * :%d\n",sizeof(double *));
}
运行结果:
64位测试代码:
#include<stdio.h>
int main(){
printf("64位:\n");
printf("char :%d\n",sizeof(char));
printf("char* :%d\n",sizeof(char *));
printf("short :%d\n",sizeof(short));
printf("short *:%d\n",sizeof(short *));
printf("int :%d\n",sizeof(int));
printf("int * :%d\n",sizeof(int *));
printf("long int :%d\n",sizeof(long int));
printf("long int * :%d\n",sizeof(long int *));
printf("long long int :%d\n",sizeof(long long int));
printf("long long int * :%d\n",sizeof(long long int *));
printf("float :%d\n",sizeof(float));
printf("float * :%d\n",sizeof(float *));
printf("double :%d\n",sizeof(double));
printf("double * :%d\n",sizeof(double *));
}
运行结果: