Char

Hi...i'm trying to put some characters into a vector but i only get the first 2 of them.
Example:abca
output: ab


1
2
3
4
5
6
7
while(cin>>c){
    q.push_back(c);
}
for(i=0;i<q.size();i++){
    cout<<q[i];
    q.pop_back();
}
Remove line 6.

The first two times through the loop, you're removing the last two characters, therefore q.size() becomes 2 and the loop terminates.
thanks
Topic archived. No new replies allowed.