atoi_字符数组转换为整数函数 - waiting...'s Blog

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

waiting... posted @ 2009年3月02日 09:25 in C/C++ with tags atoi 字符 数组 转换 整数 函数 , 2660 阅读

 

 

  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. }

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee