title: I want to create a function in c++ to read a file having the file as an argument, but I have problems when I compile the program
body: <p>This is the function that read the file</p>
  
  <pre><code>void read_function(istream&amp; filename, vector&lt; vector&lt;double&gt; &gt;&amp; v)
  {
  //vector&lt;vector&lt;double&gt; &gt; v;
      if (filename)
      {
          string linea; 
          int i = 0;
          while (getline(filename, linea))
          {
              v.push_back(vector&lt;double&gt;());
              stringstream split(linea);
              double value;
              while (split &gt;&gt; value)
              {
                  v.back().push_back(value);
              }           
          }
      }
  };
  </code></pre>
  
  <p>The main function </p>
  
  <pre><code>int main(int argc, char const *argv[]){
  
  if (argc &lt; 2)
  {   
      cerr &lt;&lt; "input file's name\n"&lt;&lt; endl;
  }   
  
  string program_name = argv[0];
  ifstream input;
  input.open(argv[1]);
  
  vector&lt; vector&lt;double&gt; &gt; array;
  
  for (int i = 0; i &lt; array.size(); i++) 
  {             
      for (int j = 0; j &lt; array[i].size(); j++) 
          cout &lt;&lt; read_function(argv[1], array) &lt;&lt; '\t';    
          cout &lt;&lt; endl;
  }
  
  return 0;
  }
  </code></pre>
  
  <p>When I compile the code I get the following errors messages</p>
  
  <p>error: invalid initialization of reference of type ‘std::istream&amp; {aka std::basic_istream&amp;}’ from expression of type ‘const char*’
        cout &lt;&lt; read_function(argv[1], array) &lt;&lt; '\t';</p>
  
  <p>error: in passing argument 1 of ‘void read_function(std::istream&amp;, std::vector >&amp;)’
   void read_function(istream&amp; filename, vector&lt; vector >&amp; v)</p>