Input multiple values in one line... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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...

24th Jun 2020, 7:33 AM
Aminul
Aminul - avatar
3 Answers
+ 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)
24th Jun 2020, 7:43 AM
Ipang
+ 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.
24th Jun 2020, 7:47 AM
Mustafa K.
Mustafa K. - avatar
0
Thanks but I need in c++...
24th Jun 2020, 7:37 AM
Aminul
Aminul - avatar