atoi_字符数组转换为整数函数 - waiting...'s Blog
atoi_字符数组转换为整数函数
-
#include <iostream>
-
#include <cstdlib>
-
using namespace std;
-
-
int main()
-
{
-
char year1[]= "2009";
-
int intYear = atoi(year1);
-
cout << intYear << endl;
-
string year2 = "2010";
-
intYear = atoi(year2.c_str());
-
cout << intYear << endl;
-
return 0;
-
}