char 与 int之间的转换 https://blog.youkuaiyun.com/smilesundream/article/details/77881995
cout 输出string https://www.cnblogs.com/mzct123/p/4876185.html
C++字符串操作 https://www.cnblogs.com/lidabo/p/3487043.html
iomanip用法 https://blog.youkuaiyun.com/qq_37336280/article/details/81708527
#include <iostream>
#include<string> //有此头文件可以cout输出字符串
#include<iomanip> //有此头文件可以对cout操作加以限定(增加操作属性)
using namespace std;
int main ()
{
{ //常见数据类型,存储展示
long l = 11.22; //整数型数据,在赋值过程中,转换为整型,舍弃小数点数据
cout << l << endl; //11
float f = 12.34567; //float 小数点后4位数据
cout << f << endl; //12.3457
double d = 30949.3574;
cout << d << endl; //30949.3
}
{ //char型字符存储数字,
short s =90;
cout << s << endl; //90
char h = 90; //数字可以直接赋值给 char变量,但是字符内容需经过指针
cout << h << endl; //Z //ASCAll码的展示用char型
}
{//char型字符转换成数字方式,cout输出方式
char hh = 90;
int aa = (int)hh; //"字符数字"转化为int型数据 ,使用强制类型转换
cout << aa <<endl; //90 10进制形式
cout <<setbase(16)<<setfill( '*' )<<setw(6)<<aa<<endl; //****5a //填充"*",显示16进制的数据90=5a
}
{
char tt[] = "+";
cout << tt << endl; //字符 用char展示,用数组形式
}
{// char 字符串与string 共同可以展示一串字符
char s2[10] = "qwerty+="; //字符串字符部分的定义,需要用指针/数组形式
cout << s2 << endl; //qwerty+=
char* s1 = "hellow char--%%";
cout << s1 << endl; //hellow char--%%
string str = "hellow string++**";
cout << str << endl; //hellow string++**
char bb = str.at(3); //取出字符串中某一字符
cout << bb << endl; //l
int cc = (int)bb; //对字符进行数据转换
cout << cc << endl; //6c //16进制形式
}
system( "PAUSE ");
return 0;
}