C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
C++ strtok function during compile Eclipse says not declared in scope?
我正在练习一些C++但我在拆分用户输入时遇到问题。我正在使用 eclipse ide 2020-03,带有 mingw32-gcc-g++-bin 9.2.0-1。下面是我的代码,
#include <iostream>
#include <string>
using namespace std;
int main() {
string orderbook_symbol[500000][8]; //orderid, ordertime, symbol, buy/sell, qty, price, exp time, strike
string user_order;
char * pch;
string done= "done trading";
while(user_order.compare(done) != 0) {
cin >> user_order;
pch = strtok(user_order," ");
}
}
当我点击编译时,我看到此错误:
23:22:06 **** Incremental Build of configuration Debug for project stasd ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src\stasd.o" "..\src\stasd.cpp"
..srcstasd.cpp: In function 'int main()':
..srcstasd.cpp:26:9: error: 'strtok' was not declared in this scope; did you mean 'strtol'?
26 | pch = strtok(user_order," ");
| ^~~~~~
| strtol
23:22:06 Build Failed. 1 errors, 0 warnings. (took 560ms)
我在这里举了一个例子:http://www.cplusplus.com/reference/cstring/strtok/而且我不明白为什么函数调用不在范围内错误。
你包括<string>
,而strtok
是<string.h>
或<cstring>
的一部分。
看 包括字符串或字符串。 对于这些之间的差异。
相关文章:
- 错误:未在此范围内声明'reverse'
- 错误:"imread"未在此范围内声明
- 未在此范围内声明错误 'xy'
- Socklen_t未在此范围内声明
- 错误:'[' 之前预期的非限定 id 和错误:'users'未在此范围内声明
- "Main"已在当前范围内声明
- c++ 变量在宏的扩展中没有在这个范围内声明
- C++ 在编译过程中 strtok 函数 Eclipse 说没有在范围内声明?
- 'num1'未在此范围内声明
- 如何找到在本地范围内声明的变量的地址?
- NT状态未在此范围内声明
- 变量未在此范围内声明 数组线性搜索
- 包含文件中的 Typdef "未在此范围内声明"
- 'ClassName'和'ClassInstance'未在此范围内声明
- C++ 中的类之间的数据重新循环 - 错误:'<class name>'未在此范围内声明
- 代码作为 C 文件工作,但不作为C++文件,错误:'__builtin_types_compatible_p'未在此范围内声明
- 如何修复错误:"vreinterpretq_u32_f64"未在此范围内声明 - 在Android上使用Eigen构建
- 如何修复C++中的"arrStud未在此范围内声明"错误
- 错误:"SHGetKnownFolderPath"未在此范围内声明
- 错误:'Sprite'未在此范围内声明