I am new to C++ and learning vectors. Want to read input as below and using string vectors.
2
stack
overflow
3
stack
heap
overflow
Below is my code.Here, getting only 1 string as output. Please point out where I am making mistake.
int main() {
vector<string> my_strings;
string buf;
int n;
cin >> n;
for(int i=0;i<n;i++){
getline(cin,buf);
my_strings.push_back(buf);
}
for(int i=0;i<n;i++){
cout << my_strings[i] << endl;
}
return 0;
}