1

I am trying to split the sentence into words by checking the characters from the string one by one.

#include <iostream>

using namespace std;

int main()
{
    string a;
    getline(cin,a);
    string word = "";
    for(int i=0;i=a.size();i++)
    {
        if(a[i]==" ") //error iso here
        {
            cout<<word<<endl;
            word="";
        }
        else
        {
            word+=a[i];
        }
        cout<<word<<endl;
    }

}
4

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.