heyy all ,, i'm trying to get the middle word of sentence contains 3 words using find and substr..
this is the code :
#include <iostream>
#include <string>
using namespace std;
void main()
{
string sentence;
cout << "enter a three-words sentence :";
getline(cin, sentence);
string middle = sentence.substr(sentence.find(" ") + 1, sentence.find(" ")); // find the middle word
cout << middle << endl; //Print the middle word
system("pause");
}
so guys what is the solution!!please be helpful :) <3