- 返回上层目录
- substr提取部分字符串
- c_str()转为char*数组
- to_string数值转字符串
- [char[],char *,string之间转换](#char[],char *,string之间转换)
- string赋值
string str_new = str.substr(0, length);
const char* cstr = str.c_str();
功能:将数值转化为字符串。返回对应的字符串。
函数原型:
string to_string (int val);
string to_string (long val);
string to_string (long long val);
string to_string (unsigned val);
string to_string (unsigned long val);
string to_string (unsigned long long val);
string to_string (float val);
string to_string (double val);
string to_string (long double val);
#include <iostream>
using namespace std;
string num1 = string("111");
string s;
s.push_back(1 + '0');