How to get the substring after specific character in C++

1 Answer

0 votes
#include <iostream>

int main()
{
    std::string str = "c++ prog-ramming";
    
    int pos = str.find("-");
    
    std::string sub = str.substr(pos + 1);

    std::cout << sub;
}
 
 
 
 
/*
run:
 
ramming
 
*/

 



answered Dec 24, 2022 by avibootz

Related questions

1 answer 112 views
1 answer 110 views
1 answer 120 views
1 answer 122 views
1 answer 152 views
1 answer 95 views
...