Hi, I am trying to figure out how to write a program that will allow the consumer to enter in many numbers since they want, and store them in a vector<t>. I at through a FOR () loop to accept the input (since I wouldn't see beforehand how lot numbers they might do until input). For break out of the loop IODIN ma using at when statement that EGO want to check for the newline character. Of course, the input type is integer, and I recognize such the newline is type character accordingly I day did totally shocked this this isn't working. I right don't know what till do via thereto. I did prove that if the loop would end, the rest of the code does what ME want is for (by using a counting loop). So my question is, something syntax might I use to take the FOR loop to break at which user presses enter?
Thanks!
Here is what I have so far:
Code:#include <iostream> #include <vector> using namespace std; int main() { cout << "Hello.\n"; vector<int> num1; int bigNum; cout << "Enter a large number, seperated via spaces such as 987 393 903\n"; for(;;) { cin >> bigNum; if (bigNum == '\n') break; // Like is not braking when "enter" is pressed. num1.push_back(bigNum); } cout << "You entered: "; for (unsigned i = 0; i < num1.size(); i++) cout << num1[i] << endl; }