1. 程式人生 > >int double std:string之間的互轉

int double std:string之間的互轉

1 /*2 (C) OOMusou 2008 http://oomusou.cnblogs.com3 4 Filename    : string_to_double.cpp
5 Compiler    : Visual C++ 9.0 / Visual Studio 2008
6 Description : Demo how to convert string to int (double)
7 Release     : 08/01/2008 1.0
8 */9 10 #include <iostream>11 #include <string>12 #include <cstdlib>13 14
 usingnamespace std;
15 16 int main() {
17 string s ="123";
18 double n = atof(s.c_str());
19 //int n = atoi(s.c_str());20 21   cout << n << endl;
22 }