-1

Is there any way to trim everything after a given character, let's say '_' . Is there any way to do that? Example:

string ul = "The quick brown fox jumped over the lazy dog________ dog dog" int ullocation = ul.find("_") (code to remove everything after the underline using the int) 
4

1 Answer 1

2

Use std::string::find() and std:string::erase(), eg:

string ul = "The quick brown fox jumped over the lazy dog________ dog dog"; string::size_type idx = ul.find("_"); if (idx != string::npos) ul.erase(idx); 

Live Demo

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.