首先说我的电脑 win7 64 位
编译器gcc 5.2.0 (32位64为兼容的)
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
printf("the byte of char is %d\n", sizeof(char));
printf("the byte of signed char is %d\n", sizeof(signed char));
printf("the byte of unsigned char is %d\n", sizeof(unsigned char));
printf("///\n");
printf("the byte of int is %d\n", sizeof(int));
printf("the byte of signed int is %d\n", sizeof(signed int));
printf("the byte of unsigned int is %d\n", sizeof(unsigned int));
printf("///\n");
printf("the byte of short is %d\n", sizeof(short));
printf("the byte of long is %d\n", sizeof(long));
printf("the byte of signed short int is %d\n", sizeof(signed short int));
printf("the byte of unsigned short int is %d\n", sizeof(unsigned short int));
printf("the byte of signed long int is %d\n", sizeof(signed long int));
printf("the byte of unsigned long int is %d\n", sizeof(unsigned long int));
printf("the byte of signed long long int is %d\n", sizeof(signed long long int));
printf("the byte of unsigned long long int is %d\n", sizeof(unsigned long long int));
printf("///\n");
printf("the byte of float is %d\n", sizeof(float));
printf("the byte of double is %d\n", sizeof(double));
printf("///\n");
printf("the byte of int * is %d\n", sizeof(int *));
printf("the byte of char* is %d\n", sizeof(char*));
printf("the byte of float* is %d\n", sizeof(float*));
printf("the byte of double* is %d\n", sizeof(double*));
return 0;
}
运行结果
我的各数据类型占字节数
char 1
int 4
float 4
double 8
short 2
long 4
long long 8
指针是 8