zl程序教程

您现在的位置是:首页 >  后端

当前栏目

【转】C++中substr的用法

C++ 用法 substr
2023-09-11 14:15:22 时间

 

substr有2种用法:
假设:string s = "0123456789";

string sub1 = s.substr(5); //只有一个数字5表示从下标为5开始一直到结尾:sub1 = "56789"

string sub2 = s.substr(5, 3); //从下标为5开始截取长度为3位:sub2 = "567"

 

转自:http://blog.csdn.net/liuchuo/article/details/54599840