[Error] ‘string‘ was not declared in this scope
程序员文章站
2022-04-04 11:18:15
...
代码如下:
#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;
即可
上一篇: Java基础编程之Java语言概述
下一篇: expected at least 1 bean which qualifies as autowire candidate(Spring Bean 无法注入)
推荐阅读
-
JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonM
-
ERROR 1366 (HY000): Incorrect string value: '\xE9\x83\x91\xE5\xB7\x9E' for column 'aa' at row 1 MySQL 字符集
-
JSON解析:com.alibaba.fastjson.JSONException: syntax error, expect {, actual string, pos xxx,...
-
Syntax error: Unterminated quoted string
-
Syntax error: Unterminated quoted string
-
error: 'to_string' is not a member of 'std'
-
error: ‘to_string’ is not a member of ‘std’
-
error: ‘to_string’ is not a member of ‘std’
-
日期转化Json异常:JSON parse error: Cannot deserialize value of type `java.util.Date` from String
-
emulator: ERROR: Can‘t find ‘Linux version ‘ string in kernel image file