摘要:
c_str(): 返回const char*类型(可读不可改)的指向字符数组的指针。#include <iostream>#include <stdlib.h>#include <string>int main(){std::string ss("stri");const char *p;p = ss.c_str();std::cout<<*p<<std::endl;return 0;}运行结果:s#include <iostream>#include <stdlib.h>#include 阅读全文
摘要:
名字来源:array to floating point numbers 的缩写用 法: double atof(const char *nptr);#include <iostream>#include <stdlib.h>#include <string>int main(){//std::string ss("478");char *str = "123";double f_ss;f_ss = atof(str);std::cout<<f_ss/2<<std::endl;return 0; 阅读全文