http://www.cplusplus.com/reference/clibrary/cstdlib/atof/
double atof(const char *nptr)函數可以將一個字符串變成浮點數。
#include<iostream>
using namespace std;
int main()
{
double f;
char*str=”123.456”;
f=atof(str);
cout<<f<<endl;
}
具體看上面鏈接.
把字符串變成整型的函數爲
int atoi ( const char * str );
用法與atof類似;
參考http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/