waiting...'s Blog

atoi_字符数组转换为整数函数

 

 

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.         char year1[]= "2009";
  8.         int intYear = atoi(year1);
  9.         cout << intYear << endl;
  10.         string year2 = "2010";
  11.         intYear = atoi(year2.c_str());
  12.         cout << intYear << endl;
  13.         return 0;
  14. }




Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee