Chapter 3 处理数据

2018-03-15  本文已影响0人  MomToldYouSo

变量

整型数及相关

查询intlongshort的长度:

#include <climits>
int n_int = INT_MAX;
short n_short = SHRT_MAX;
long n_long = LONG_MAX;
long long n_llong = LLONG_MAX;

sizeof variable返回的是字节长度:

cout << "short is " << sizeof n_short << " bytes." << endl;
// short is 2 bytes.
cout << "int is " << sizeof(int) << " bytes." << endl;
// int is 4 bytes.

无符号变量unsigned int

cout << "Enter your agent code:________\b\b\b\b\b\b\b\b";
long code;
cin >> code;
// 将在打印完下划线后退回第一个下划线前等待输入

布尔值

只有零值才为false,其他均为true

bool start = -100; // start = true
bool end = 0; // end = false

const限定符

const#define好:

浮点数

上一篇 下一篇

猜你喜欢

热点阅读