c++ - Trying to use int in getline -


cout << "how many questions there going on exam?" << endl; cout << ">>"; getline(cin, totalquestions); 

this small piece of code comes function in class have created , need totalquestions int can run through loop , keep asking total amount of questions have asked.

question q; for(int = 0; < totalquestions; i++) {     q.inputdata();     questions.push_back(q); } 

where piece of code comes play? have idea make work?

use

cin >> totalquestions; 

check errors too

if (!(cin >> totalquestions)) {     // handle error } 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -