C各种类型变量所占字节

首先说我的电脑 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值