I have input like this:
1581 303 1127 Bravo
I want to put it into strings like this:
string a="1581 303 1127";
string b="Bravo";
How can i do that?
I have input like this:
1581 303 1127 Bravo
I want to put it into strings like this:
string a="1581 303 1127";
string b="Bravo";
How can i do that?
You can do something like this:
A way in standard C++ that doesn't rely on reading the values is
a simpel c++ style approach would be using
std::to_string
this adds an " int" value at the end of your string.
But have you consider using string streams instead?
and if you wish convert it to an good old string:
Just read them as strings and put them together.
Based on the fact that you take first three as int and last as string do it like this.
int i1, i2, i3; //Take input in three integers sprintf(a, "%d %d %d", i1, i2, i3);