https://blog.csdn.net/ch_vaniteux/article/details/79247061
string str(tobeornottobe);
string ptr;
ptr = str.substr(4, 5);
cout << ptr;
输出的结果是ornot
可以说,substr是一个给定起点和截取长度,截出字符串中一段的函数
如果substr(4)就会是ornottobe 即到结尾
https://blog.csdn.net/ch_vaniteux/article/details/79247061
string str(tobeornottobe);
string ptr;
ptr = str.substr(4, 5);
cout << ptr;
输出的结果是ornot
可以说,substr是一个给定起点和截取长度,截出字符串中一段的函数
如果substr(4)就会是ornottobe 即到结尾
转载于:https://www.cnblogs.com/fengzhongzhuifeng/p/10876261.html