0

** Im currently want to use whole string that it should contain space between them so Im using getline() function but after code getline() my code is getting terminated,I dont know why this happening**


using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        
        int n;
        cin >> n;
        while (n--)
        {
            string m;
            getline(cin, m);
            string s1 = m.substr(1);
            string s2 = m.substr(6);
            string s3 = m.substr(9);
            string s4 = m.substr(15);
            cout << s1 << s2 << s3 << s4 << endl;
        }

    }
    return 0;
}```

1 Answers1

0

Try using this:

char input[100];
cin.getline(input, sizeof(input));
string str = input;
cout << str.substr(1) << " " << str.substr(6) << " " << str.substr(9) << " " << 
str.substr(15) << "\n";
Prasang
  • 11
  • 4