1001. A+B Format 字符串

题目及答案链接

https://www.liuchuo.net/archives/1888

c++ 有关 字符串 和各种类型的转换

#include <string>

string a; 

a=to_string(b);  //b可以是 任何基础  【数值】 类型 不包括 char

#include <cstdlib>

valT=atox(b)  //x可以换成 i l f,b必须是char * 类型;因为这个函数是从c来的

        //atox 是ascii to x  的意思,atoi 字符串转整形,atol 串转长整,atof 串转double

valT=strtox(char*a,char*b)  //x可以是l ul d  ,算是atox的改良版,strtol 串转long int ,strtoul 串转无符long , strtod 串转double

              //第一个参数和atox(b)的b类似,是字符串,不过只要求串中存在一个能正常转换

        

猜你喜欢

转载自www.cnblogs.com/mgfsos/p/10575996.html