1、用atoi()
#include <stdlib.h>
int atoi(const char *nptr);
作用:字符串转换成整型数
2、用sscanf()
3、整型转字符串:sprintf、string的to_string()
int main()
{
int n = 1;
string c = std::to_string(n);
cout << c.c_str();
}
4、使用字符串流
istringstream iss(line); //输入流
int key, value;
iss >> key >> value;