c++中用于stoi关键字的库
what library to use for stoi keyword in c++
我的问题很简单,但我似乎找不出来。我想知道使用stoi
时包含什么库。我用的是atoi
,
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
但是当我用stoi
运行时,我得到"stoi未声明"。由于
您需要#include <string>
并使用理解c++ 11的编译器。最小的例子:
#include <string>
#include <cassert>
int main()
{
std::string example = "1234";
int i = std::stoi(example);
assert(i == 1234);
return 0;
}
例如,用g++ -std=c++11
编译
相关文章:
- Visual Studio 2015:Extern "C" 和 "export" 关键字
- C++中的"inline"关键字
- 如何确保C++函数在定义之前声明(如override关键字)
- 有人知道为什么在开关中使用stoi函数会返回恒定的错误吗
- 谷歌模拟和覆盖关键字
- 结构体 S { int align; } 之间的区别;(struct 关键字后的名称)和 struct { int al
- 如果全局变量默认是外部变量,为什么要添加"extern"关键字?
- 当我从下面的代码中删除关键字 virtual 时,它可以正常工作,否则会出现错误。在这里"virtual"字的意义是什么?
- 为什么"delete"关键字不删除节点?
- 在 c++ 中正确定义"this"关键字?
- 这个额外的关键字在这个 c++ 类声明中是什么意思?
- 在 typedef 内部使用 const 关键字和在 typedef 外部使用 const 关键字之间有区别吗?
- C++ - 为什么这里需要'template'关键字?
- C++函数的关键字?
- 使用 'typename' 关键字将非类型视为依赖上下文中的类型
- std::stoi 的版本拒绝任何非数字
- "friend"关键字在C++中是什么意思?
- 声明C++数组(带或不带 "new" 关键字)
- 对齐和对齐的实际用例C++关键字
- c++中用于stoi关键字的库