title: how to get return value from the the subroutine functrion to the main function?
body: <p>I would like to ask very simple question that sometime make me confuse.</p>
  
  <p>I want to get a value from the subroutine function, but I tried many ways still don't get it out, </p>
  
  <p>Here is my code:</p>
  
  <pre><code>void Read_line (string filename)
  {
      int number_of_lines = 0;
      std::string line1;
      std::ifstream myfile(filename.c_str());
  
      while (std::getline(myfile, line1))
      {
          ++number_of_lines;
      }
      cout &lt;&lt; "Number of lines in text file: " &lt;&lt; number_of_lines;
  
  //  return number_of_lines;
  }
  
  int main ()
  {
  
      string name = "gbm";
      double WEEK = 1930;
      double DAY = 0;
  
      string week = boost::lexical_cast&lt;string&gt;(WEEK);  // convert number to string
      string day  = boost::lexical_cast&lt;string&gt;(DAY) ;  // convert number to string
  
      string filename = name + week + day + ".sp3";
      int number_of_lines = Read_line(filename);
  
     // my expectation to have "number_of_lines" value in here
  
     cout &lt;&lt; "Number of lines in text file: " &lt;&lt; number_of_lines;
  
  }
  </code></pre>
  
  <p>Thank you for helps.</p>