push_back is not working

In the code below, I tried to let the user input text, and it would output the first word. However, whenever I try the program to input the text, it doesn't output anything.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <vector>

using namespace std;

int main()
{
vector<string> words;
for(string winput; cin>>winput; )
words.push_back(winput);

cout << words[0];
}
Works just fine for me.
Here's two examples of the program running with the input "hello world":
http://coliru.stacked-crooked.com/a/afdbe7c9bb25edbd

Note that if you are using the program interactively, you need to signal end-of-input by entering Ctrl-D (Ctrl-Z on windows) at the terminal. If you don't, it'll just keep waiting forever for more input.

How did you arrive at the conclusion that push_back is the problem?
To be certain that the code will compile cleanly on all conforming implementations, #include <string>
Topic archived. No new replies allowed.