0

I am trying to asign more than one words to a variable, at once, but after inserting space, it looks for another variable. Lets say I need to write Hello c++ world in a variable. The onliest solution I've found, is the following C++ code:

#include <iostream>
using namespace std;
int main()
{
    string word1,word2,word3;
    cin>>word1>>word2>>word3;
    return 0;
}

Ok, but what if you dont know how much words is the sentance going to be?

Example entry: say Hello there!
Example print: Hello there
Example entry: say This is much longer, we can't create milions of variables!
Example print: This is much longer, we can't create milions of variables!

Please help! What I need here is not only use spaces in a variable, I want before this to have another "command" like in the case above: the command say.

undefined
  • 1,019
  • 12
  • 24

0 Answers0