0
Input multiple values in one line...
How can I input multiple values in one line... For example (string x="apple",y="orange",z="banana";) this are selected values... But I need to store value like, string a; getline(cin, a); This function store all value in one... "apple orange banana"; But I want to store different value... Input value example: Input: apple orange banana Value store: {" apple","orange","banana"}... If any one understand what I want to know, please suggest me... Thank you...
4 Antworten
+ 1
Aminul
Are you asking about how to split the sentence and store the chunks into some container?
Here's one way with vector
https://code.sololearn.com/cH2BQul22Xls/?ref=app
(Edited)
+ 1
string x, y, z;
cin>> x >> y >> z;
When you enter your input like this,
"apple orange banana" (without quotation marks ), x will be assigned to apple, y to orange and so on.
0
Thanks but I need in c++...