How to Show a sentence using string function

There is a sentence "C ++ is an easy language" how to get the word "EASY" from the sentence by using the C ++ string function? Give the script too
What do you mean by get?

Get the 5th word?
Get the word beginning with 'e'?
Get the word with 4 letters?

https://www.cplusplus.com/reference/string/string/
Scroll down to " String operations:"
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <string>

int main()
{
	const std::string sent {"C ++ is an easy language"};

	if (const auto easy {sent.find("easy")}; easy != std::string::npos)
		std::cout << sent.substr(easy, sent.find_first_of(' ', easy) - easy) << '\n';
}



easy

Hello ninetails99,

As salem c suggested start at his link and check out the find functions along with "substr" function.

Andy
Registered users can post here. Sign in or register to post.