title: vector in function - how to do return
body: <p>I've got a function that should read from file line by line, the reading stops when a line does not begin with '>' or ' '. It should store the lines in vector and return it. <br>This is code:<br></p>
  
  <pre><code>    #include &lt;cstdlib&gt;
      #include &lt;iostream&gt;
      #include &lt;string&gt;
      #include &lt;stdio.h&gt;
      #include &lt;fstream&gt;
      #include &lt;vector&gt;
  
      using namespace std;
  
      string getseq(char * db_file) // gets sequences from file
              {
                  string seqdb;
                  vector&lt;string&gt; seqs;
                  ifstream ifs(db_file);
                  string line;
  
                  //vector&lt;char&gt; seqs[size/3];
  
                  while(ifs.good())
                  {
                      getline(ifs, seqdb);
                      if (seqdb[0] != '&gt;' &amp; seqdb[0]!=' ')
                      {
                          seqs.push_back(seqdb);
                      }
                  }
  
              ifs.close();
              //return seqs;
  
              //return seqs;
              }
  
      int main(int argc, char * argv[1])
      {
          cout &lt;&lt; "Sequences: \n" &lt;&lt; getseq(argv[1]) &lt;&lt; endl;
          return 0;
      }
  </code></pre>
  
  <p>Compiler (g++) returns:<br></p>
  
  <pre><code>    fasta_parser.cpp: In function ‘std::string getseq(char*)’:
      fasta_parser.cpp:32: error: conversion from ‘std::vector&lt;std::basic_string&lt;char, `std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;’ to non-scalar type ‘std::string’ requested`
  </code></pre>
  
  <p>Anyone has any idea?</p>
  
  <p>Edit:
  As Skurmendel ask, I am adding whole code because of memory security violation after </p>
  
  <p>executing compiled code: <br><br></p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;stdio.h&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  vector&lt;string&gt; getseq(char * db_file) // pobiera sekwencje z pliku
          {
              string seqdb;
              vector&lt;string&gt; seqs;
              ifstream ifs(db_file);
              string line;
  
              //vector&lt;char&gt; seqs[size/3];
  
              while(ifs.good())
              {
                  getline(ifs, seqdb);
                  if (seqdb[0] != '&gt;' &amp; seqdb[0]!=' ')
                  {
                      seqs.push_back(seqdb);
                  }
              }
  
          ifs.close();
          return seqs;
          }
  
  int main(int argc, char * argv[1])
  {
      vector&lt;string&gt; seqs;   // Holds our strings.
      getseq(argv[1]); // We don't return anything.
  
      // This is just a matter of taste, we create an alias for the vector&lt;string&gt; iterator type.
      typedef vector&lt;string&gt;::iterator string_iter;
  
      // Print prelude.
      cout &lt;&lt; "Sekwencje: \n";
  
      // Loop till we hit the end of the vector.
      for (string_iter i = seqs.begin(); i != seqs.end(); i++)
      {
          cout &lt;&lt; *i &lt;&lt; " "; // Do processing, add endlines, commas here etc.
      }
  
      cout &lt;&lt; endl;
  }
  </code></pre>