首页 > 编程语言 >C++变量的大小

C++变量的大小

时间:2023-04-24 21:58:58浏览次数:39  
标签:变量 int float bytes long C++ 大小 byte

# include <iostream>
using namespace std;

int main() 
{
	cout << "========== BASIC VARIABLES SIZE LIST ==========" << endl;
	cout << "short: " << sizeof(short) << " bytes" << endl;
	cout << "int: " << sizeof(int) << " bytes" << endl;
	cout << "long: " << sizeof(long) << " bytes" << endl;
	cout << "long long: " << sizeof(long long) << " bytes" << endl;
	cout << "boolean: " << sizeof(bool) << " byte" << endl;
	cout << "float: " << sizeof(float) << " bytes" << endl;
	cout << "long float: " << sizeof(long float) << " bytes" << endl;
	cout << "double: " << sizeof(double) << " bytes" << endl;
	cout << "long double: " << sizeof(long double) << " bytes" << endl;
	cout << "char: " << sizeof(char) << " byte" << endl;
	cin.get();
}
========== BASIC VARIABLES SIZE LIST ==========
short: 2 bytes
int: 4 bytes
long: 4 bytes
long long: 8 bytes
boolean: 1 byte
float: 4 bytes
long float: 8 bytes
double: 8 bytes
long double: 8 bytes
char: 1 byte

标签:变量,int,float,bytes,long,C++,大小,byte
From: https://www.cnblogs.com/cloucodeforfun/p/17351043.html

相关文章

  • C++第四章课后习题选做
    #include<iostream>usingnamespacestd;classDate{private:intyear,month,day;public:Date(intyear=1,intmonth=1,intday=1){this->year=year;this->month=month;this->......
  • 斯坦福 UE4 C++ ActionRoguelike游戏实例教程 15.创建持续效果BUFF
    斯坦福课程UE4C++ActionRoguelike游戏实例教程0.绪论概述本篇文章对应Lecture18–CreatingBuffs,WorldInteraction,71、72节。将会基于之前实现的SurAction能力系统,教你如何定义和创建拥有持续效果的BUFF,例如许多游戏常见的灼烧、中毒效果。目录分析创建BUFF基类......
  • 斯坦福 UE4 C++ ActionRoguelike游戏实例教程 16.优化交互,实现看到物体时出现交互提
    斯坦福课程UE4C++ActionRoguelike游戏实例教程0.绪论概述本篇文章对应Lecture18–CreatingBuffs,WorldInteraction,73节。本文将会重构以前实现过的SurInteractionComponent,实现在玩家注释可交互物体时,可以出现可交互提示,效果如下:在文章的最后,我会放出所有相关的代......
  • 实用软件Caps大小写提示
    电脑输入法需要频繁切换大小写,没有提示很难受,联想电脑一直都有提示,最近发现在微软商店可以下载LenovoHotkeys。安装即可使用......
  • 1 Go语言介绍、 2 Go开发环境搭建 、3 第一个helloworld 、4 变量命名规范 、5 变量的
    目录1Go语言介绍2Go开发环境搭建3第一个helloworld4变量命名规范5变量的定义和使用1Go语言介绍#Go语言介绍Go即Golang,是Google公司2009年11月正式对外公开的一门编程语言Go是【静态强类型】语言,是区别于解析型语言的编译型语言(静态:类型固定强类型:不同类型不允许直接......
  • C/C++服务端客户端通讯程序[2023-04-24]
    C/C++服务端客户端通讯程序[2023-04-24]Socket通讯程序..服务器端).pptx任务:Socket通讯程序开发·基本要求(80分)∶完成一对一的Socket客户端与服务器程序·进阶要求(90分)∶在完成基本要求基础上,将服务器端程序改为多线程程序·高级要求(100分)︰将客户端和服务器端都改为多......
  • 面试最常问的数组转树,树转数组 c++ web框架paozhu实现
    刚毕业同学,找工作常被问二维数组转树,树转二维数组需要支持无限层级实现,如果你了解这个语言那么实现起来还要一番思考c++web框架paozhu使用需要实现数据库表数据到前台菜单实现,就是这种功能二维数组转树,树转二维数组保存时候树二维数组,展示时候树树状。这个技术难点在于无......
  • 初学者代码训练Day7(c/c++)
    兔子产子问题要求 流程图  代码1#include<iostream>2usingnamespacestd;34intmain()5{inta=1,b=1,sum=0,y;6printf("%d\n%d\n",a,b);7for(y=3;y<=30;y++)8{sum=a+b;9printf("%d\n",sum);10a=b;1......
  • 【c&c++】[Error] iostream.h: No such file or directory的解决办法
    直接上错误代码实例#include<iostream.h>intmain(){print('hello,world\n')return0;}编译通不过,直接出错 这是C语言转C++的两条经典错误C++中是没有iostream.h这个东西的(或者一般不会这么使用),正确用法是:#include<iostream>用了iostream还不......
  • 【c&c++】VScode报错error: ‘::main‘ must return ‘int‘ void main()
    在运行指针时终端出现error:‘::main’mustreturn‘int’voidmain()错误。源代码如下:#include<stdio.h>voidmain(){inta,*p,b,c,d,e;a=100;p=&a;/*(*&a)先进行&a运算,得a的地址,再进行*运算,即变量a的值*/b=*&a;printf("a=%d\n",a);......