代码如下:
#include<iostream>
#include<string>
//using namespace std;
int main()
{ //其实就是对ASCii表的操作
string s;
char a = 'a';
int b = a - '0'; //字符转成数字
int c = (int)a; //就是ASC码十进制值,不加(int)也会隐式转
char ch=b+'0'; //数字转成字符
char d = a + 32; //转小写
char f = a - 32; //转大写
return 0;
}
出现错误: [Error] 'string' was not declared in this scope
使用的是DEV C++ 5.11版本,一开始我以为是编译器环境没有 C++11标准,所以配置了一下编译器,如下:
在这里写入 -std=c++11 打勾并确定
后面搜索到一个网址,里面给出了解决方案,原来是没加命名空间,所以把代码中的注释去掉:using namespace std;
即可