更新时间:2022-11-19 09:06:48
将其更改为:
int y = atoi(s.c_str());
或使用 std::stoi()
,您可以通过
or use std::stoi()
which you can pass a string
directly:
int y = stoi(s);
您的程序还有其他几个错误.可行的代码可能类似于:
You program has several other errors. Workable code could be something like:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s = "453";
int y = atoi(s.c_str());
// int y = stoi(s); // another method
}