unsigned long stringToNum(const string& str) //string 到數字 { istringstream iss(str); unsigned long num; iss >> num; return num; } string numToString(unsigned long d) { //數字到string stringstream ss; ss <<std::fixed<< d; return ss.str(); }
使用的時候須要導入sstream頭文件spa