How can i get data by keyboard using push_ back? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i get data by keyboard using push_ back?

I have to make a program that asks for user data and store them using push_back. A little help please!!! Using c++.

4th Dec 2018, 4:10 PM
Osvaldo Gonzalez Campos
Osvaldo Gonzalez Campos - avatar
2 Answers
+ 6
The push_back operation is supported by STL containers like vector, list, queue and stack. The best thing to use for this case would be a vector. Use a loop to keep reading a character till the input stops or fails, and push_back the character into a vector of characters. As for the code, try making it yourself now, and let us know if you get stuck. We will be happy to help.
4th Dec 2018, 4:18 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
Thanks!!! I'll try that.
4th Dec 2018, 4:22 PM
Osvaldo Gonzalez Campos
Osvaldo Gonzalez Campos - avatar