#include<iostream>
using namespace std;
cout 输出
float a=3.14; 先是double,再转换成float
字符的强制性转换
char a='a';
cout << "a =" <<(int)a<<endl; 把字符a强制性转换为十进制的ASCLL值。
// a=97,A=65
转义字符
一些不能显示出的ASCLL字符。
输出\
cout << "\\"<<endl;
\t有8个空格。
如果要输入更整齐。
c++风格字符串:string 变量名="字符串"需要头文件#include<string>
布尔类型bool
bool a=true;
a=false; 本质上1代表真,0代表假
bool占的内存大小为1.
数据的输入
作用:从键盘获取数据
关键子:cin
int a;
cin >> a;
cout<<"a的值为:" <<a<< endl;
string a="hello";
cin >> a;
cout<<"a的值为:" <<a<< endl;