C各种类型变量所占字节
2016-04-08 12:29
417 查看
首先说我的电脑 win7 64 位
编译器gcc 5.2.0 (32位64为兼容的)
运行结果
![](https://img-blog.csdn.net/20160408122638477)
我的各数据类型占字节数
char 1
int 4
float 4
double 8
short 2
long 4
long long 8
指针是 8
编译器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
相关文章推荐
- MySQL中的integer 数据类型
- 如何组织构建多文件 C 语言程序(二)
- MySQL 数据类型
- 如何写好 C main 函数
- PostgreSQL教程(四):数据类型详解
- Lua学习笔记之数据类型
- 实现Lua中数据类型的源码分享
- Lua和C语言的交互详解
- Lua数据类型介绍
- SQL 研究 相似的数据类型
- 详解SQLite中的数据类型
- PowerShell中使用GetType获取变量数据类型
- c# 数据类型占用的字节数介绍
- C#难点逐个击破(6):C#数据类型与.net framework数据类型
- C#、ASP.NET通用工具类IsWhat?(可以判断数字、身份证、数据类型等等)
- 关于C语言中参数的传值问题
- 简要对比C语言中三个用于退出进程的函数
- 深入C++中API的问题详解
- 基于C语言string函数的详解
- C语言中fchdir()函数和rewinddir()函数的使用详解