title: Passing variable (array type) from function to "main" scope Type: std::tr1::match_results<std::string::const_iterator>
body: <p>I would like to pass the variable from a function to the main scope which I'm calling, I'm trying to do like I use to do in C but it returns nothing.</p>
  
  <p>I want to be able to output and deal with it after the return of the function</p>
  
  <pre><code>#include "StdAfx.h"
  #include &lt;regex&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;conio.h&gt;
  using namespace std;
  
  std::tr1::match_results&lt;std::string::const_iterator&gt; match(std::string&amp; regex, const std::string&amp; ip,std::tr1::match_results&lt;std::string::const_iterator&gt; res)
  {
     const std::tr1::regex pattern(regex.c_str());
     bool valid = std::tr1::regex_match(ip, res, pattern);
     std::cout &lt;&lt; ip &lt;&lt; " \t: " &lt;&lt; (valid ? "valid" : "invalid") &lt;&lt; std::endl;
     cout &lt;&lt; "FIRST RES FOUND: " &lt;&lt; res[1] &lt;&lt; endl;  
     return res;
  }
  
  int main()
  {
  
     string regex = "(\\d{1,3}):(\\d{1,3}):(\\d{1,3}):(\\d{1,3})";
     string ip = "49:22:33:444";
     std::tr1::match_results&lt;std::string::const_iterator&gt; res;
     match(regex,ip.c_str(), res);
  
     cout &lt;&lt; "Result &gt;" &lt;&lt; res[1] &lt;&lt; "&lt; " &lt;&lt; endl;
  
  
     _getch(); return 0;
  }
  </code></pre>
  
  <p>When I compile and run, The output is: "FIRST RES FOUND: 49
  Result >&lt;"</p>
  
  <p>It's probably a really simple solution but what do I have to do to set it for my main can read it correctly as in: "Result >49&lt;"</p>
  
  <p>Thanks in advance. :)</p>