我想将两个char *类型的变量转换为cpp
中的intchar* lower = "552"
char* higher = "882"
这两个变量是数字,但在char *的类型中,如“552”,我想将它们转换为int,如:
int e = 552 //which 552 is converted from char*
CPP是否有为我这样做的功能?
答案 0 :(得分:0)
http://www.cplusplus.com/reference/string/stoi/
#include <string>
void main ()
{
char *lower = "552";
int e = stoi(lower);
}
答案 1 :(得分:0)
是的,试试sstream!
#include <sstream>
using namespace std;
void main()
{
sstream s;
char * lower = "552";
int i;
s<<lower;
s>>i;
}