C++ 数据类型
C++ 数据类型
2023-09-14 09:09:14 时间
https://www.runoob.com/cplusplus/cpp-data-types.html
#include <iostream>
#include <limits>
using namespace std;
int main()
{
cout << "type: \t\t"
<< "************size**************" << endl;
cout << "bool: \t\t"
<< "所占字节数:" << sizeof(bool);
cout << "\t最大值:" << (numeric_limits<bool>::max)();
cout << "\t\t最小值:" << (numeric_limits<bool>::min)() << endl;
cout << "char: \t\t"
<< "所占字节数:" << sizeof(char);
cout << "\t最大值:" << (numeric_limits<char>::max)();
cout << "\t\t最小值:" << (numeric_limits<char>::min)() << endl;
cout << "signed char: \t"
<< "所占字节数:" << sizeof(signed char);
cout << "\t最大值:" << (numeric_limits<signed char>::max)();
cout << "\t\t最小值:" << (numeric_limits<signed char>::min)() << endl;
cout << "unsigned char: \t"
<< "所占字节数:" << sizeof(unsigned char);
cout << "\t最大值:" << (numeric_limits<unsigned char>::max)();
cout << "\t\t最小值:" << (numeric_limits<unsigned char>::min)() << endl;
cout << "wchar_t: \t"
<< "所占字节数:" << sizeof(wchar_t);
cout << "\t最大值:" << (numeric_limits<wchar_t>::max)();
cout << "\t\t最小值:" << (numeric_limits<wchar_t>::min)() << endl;
cout << "short: \t\t"
<< "所占字节数:" << sizeof(short);
cout << "\t最大值:" << (numeric_limits<short>::max)();
cout << "\t\t最小值:" << (numeric_limits<short>::min)() << endl;
cout << "int: \t\t"
<< "所占字节数:" << sizeof(int);
cout << "\t最大值:" << (numeric_limits<int>::max)();
cout << "\t最小值:" << (numeric_limits<int>::min)() << endl;
cout << "unsigned: \t"
<< "所占字节数:" << sizeof(unsigned);
cout << "\t最大值:" << (numeric_limits<unsigned>::max)();
cout << "\t最小值:" << (numeric_limits<unsigned>::min)() << endl;
cout << "long: \t\t"
<< "所占字节数:" << sizeof(long);
cout << "\t最大值:" << (numeric_limits<long>::max)();
cout << "\t最小值:" << (numeric_limits<long>::min)() << endl;
cout << "unsigned long: \t"
<< "所占字节数:" << sizeof(unsigned long);
cout << "\t最大值:" << (numeric_limits<unsigned long>::max)();
cout << "\t最小值:" << (numeric_limits<unsigned long>::min)() << endl;
cout << "double: \t"
<< "所占字节数:" << sizeof(double);
cout << "\t最大值:" << (numeric_limits<double>::max)();
cout << "\t最小值:" << (numeric_limits<double>::min)() << endl;
cout << "long double: \t"
<< "所占字节数:" << sizeof(long double);
cout << "\t最大值:" << (numeric_limits<long double>::max)();
cout << "\t最小值:" << (numeric_limits<long double>::min)() << endl;
cout << "float: \t\t"
<< "所占字节数:" << sizeof(float);
cout << "\t最大值:" << (numeric_limits<float>::max)();
cout << "\t最小值:" << (numeric_limits<float>::min)() << endl;
cout << "size_t: \t"
<< "所占字节数:" << sizeof(size_t);
cout << "\t最大值:" << (numeric_limits<size_t>::max)();
cout << "\t最小值:" << (numeric_limits<size_t>::min)() << endl;
cout << "string: \t"
<< "所占字节数:" << sizeof(string) << endl;
// << "\t最大值:" << (numeric_limits<string>::max)() << "\t最小值:" << (numeric_limits<string>::min)() << endl;
cout << "type: \t\t"
<< "************size**************" << endl;
system("pause");
return 0;
}
执行结果:
相关文章
- C++学习——c++逗号操作符说明(附加全部运算符优先级)
- C++STL初识,概念、六大组件、容器算法迭代器
- Effective C++第17条:要在单独的语句中使用智能指针来存储由new创建的对象
- C++0x中一些有用的新特性
- c++string截取字符串
- c++语言截取字符串,详解C++ string常用截取字符串方法
- C++ mysql connector使用方法「建议收藏」
- c++获取子类窗口句柄位置_C++中各种获取窗口句柄的方法「建议收藏」
- Android 编译C++
- C++枚举数组的排列状态
- Halcon HDEVELOP 工程导出集成到 C++ 应用程序
- C++基本概念_c语言 c++区别
- C++字符串加密_c++字符串连接函数
- c++的链表-C++实现简单链表
- C/C++ 反汇编:数据类型与常量
- C++ Taskflow QuickStart
- C/C++ 操作注册表与服务
- 【C++ 语言】引用数据类型 ( 引用数据类型定义 | 引用数据类型使用 | 引用类型参数 )
- C++:哈希:闭散列哈希表
- c++ – Linking problems due to symbols with abi::cxx11详解程序员
- C++ char数据类型(详解版)
- Sublime Text运行C和C++程序
- java和c/c++数据类型长度的比较