title: Putting strings into vector gives empty strings
body: <p>Here's part my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include&lt;string&gt;
  #include&lt;string.h&gt;
  #include&lt;algorithm&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  int main(){
      FILE *in=fopen("C.in","r");
      //freopen("C.out","w",stdout);
      int maxl=0;
      int i;
      string word;
      vector&lt;string&gt; words;
      while(!feof(in)){
          fscanf(in,"%s ",word.c_str());
          int t=strlen(word.c_str());
          if(t&gt;maxl){
              maxl=t;
              words.clear();
              words.insert(words.end(),word);
          }else if (t==maxl){
              words.insert(words.end(),word);
          }
      }
  </code></pre>
  
  <p>the problem occurs at </p>
  
  <pre><code>words.insert(words.end,word)
  </code></pre>
  
  <p>while </p>
  
  <pre><code>word
  </code></pre>
  
  <p>contains the word from my file, the vector item</p>
  
  <pre><code>words[i]
  </code></pre>
  
  <p>contains an empty string.</p>
  
  <p>How is this possible?</p>