当前位置:网站首页>C language learning record--variable basic type and memory size
C language learning record--variable basic type and memory size
2022-08-11 05:45:00 【FussyCat】
1、The memory size of different basic variable types,Compilation bits by system32位和64bits to distinguish,Where there is a difference is the typelong上,在32Compiled by a bit compiler4个字节长度,而在64It is compiled on a bit compiler8个字节.
Some people are pressingLP32 ILP32 LP64 LLP64 ILP64 To divide the byte length of the above data types,可以参考:Interpretation reference for the data model
2、Let's take a look at the above actually10种数据类型,Verify that the byte length in the table is accurate.我的PC是64位的,有32Bit of friends can take a look directly32performance on the spot.
好吧,朋友们,Forgive me for accidentally writing itC++了,该死的Visual Studio,Refill laterC了,This does not affect the byte length calculation.
#include <iostream>
using namespace std;
int main()
{
char char_a = 'a';
char str[] = "\\\\";
char str1[] = "hello";
short short_i = 1;
int int_i = 1;
unsigned uint_i = 1;
long long_i = 1;
long long llong_i = 1;
unsigned long ulong_i = 1;
float float_i = 1.0;
double double_i = 1.0;
char getstr[] = {
0 };
cout << "Hello My C!\r\n";
cout << "char_a size:" << sizeof(char_a) << endl;
cout << "short_i size:" << sizeof(short_i) << ", int_i size:" << sizeof(int_i) << ", uint_i size:" << sizeof(uint_i) << endl;
cout << "long_i size:" << sizeof(long_i) << ", llong_i size:" << sizeof(llong_i) << ", ulong_i size:" << sizeof(ulong_i) << endl;
cout << "float_i size:" << sizeof(float_i) << ", double_i size:" << sizeof(double_i) << endl;
cout << "str size:" << sizeof(str) << ", str1 size:" << sizeof(str1) << endl;
cin >> getstr;
}
3、可以加上unsigned的有char short int long,其他的不可以.
哦,该睡觉了...Tomorrow is another long working day...
边栏推荐
猜你喜欢
随机推荐
imx6 yocto编译备忘
阿里天池学习赛 新闻文本分类
C语言——动态内存分配常见的错误案例
信息学奥赛
QT circle函数(图片标注)
Redis - Data Types (Basic Instructions, String, List, Set, Hash, ZSet, BitMaps, HyperLogLog, GeoSpatial) / Publish and Subscribe
【C语言从初阶到进阶】第一篇 初始C语言(一)
字符与字符串
pytorch中tensor 生成的函数
0708作业---商品信息
总结:交叉验证
QT QLabel控件(使用详解)
【背包】采药题解
【备忘】从零开始搭建Yolo5训练环境
arraylist之与linkedlist
第二篇 DS5 Armv8 样例工程报错之GCC编译
[C language from elementary to advanced] Part 2 Initial C language (2)
C语言——逆序输出字符串的函数实现
Flask框架学习:模板渲染与Get,Post请求
(三)性能实时监控平台搭建(Grafana+Prometheus+Node_explorer+Jmeter)