【50 算法基础 C++】C++中substr函数的用法

版权声明:欢迎转载,请注明来源 https://blog.csdn.net/linghugoolge/article/details/87836376
#include<string> 
#include<iostream> 
using namespace std;

void main() 
{ 
string s("12345asdf"); 

//substr(i,n),从第i位开始的n个元素
//substr(i),从第i位开始到末尾
string a=s.substr(0,5);

cout<<a<<endl;
//OUT: 12345
}

猜你喜欢

转载自blog.csdn.net/linghugoolge/article/details/87836376