目录
1.2.3 变量大小
#include <iostream>
#include <iomanip>
using namespace std;
#define show(x) cout << "The size of " #x ":\r\t\t\t " << setw(2) << sizeof(x) << endl;
int main()
{
show(char);
show(short);
show(int);
show(long);
show(long long);
show(float);
show(double);
show(long double);
show(bool);
show(char *);
show(int *);
show(double *);
}
1.2.5 unsigned限定符
#include <iostream>
using namespace std;
int main()
{
short a = -1;
unsigned short b = -1;
cout << "a = " << a << endl
<< "b = " << b;
}
2.1 %的正负
#include <iostream>
#include <iomanip>
using namespace std;
#define show(x) cout << #x ":\r\t\t" << setw(2) << x << endl;
int main()
{
show(3 % 5);
show(3 % -5);
show(-3 % 5);
show(-3 % -5);
show(5 % 3);
show(5 % -3);
show(-5 % 3);
show(-5 % -3);
}
4 字符串字面量自动拼接
#include <iostream>
using namespace std;
int main()
{
cout << "abc""def";
}