title: C++ equivalent of fgets for reading from popen
body: <p>I need to process some data from standard output. Here is the code I am using:</p>
  
  <pre><code>FILE* in;
  in = popen("ls -a", "r");
  char line[256]
  while (fgets(line, sizeof(line), in) != NULL) {
      // do something with line
  }
  </code></pre>
  
  <p>Which works fine but there is a problem if the line is longer than 256 bytes. So now I tried the following but it is not a good solution:</p>
  
  <pre><code>FILE* in;
  in = popen("ls -a", "r");
  char line[100000000] // Wow
  while (fgets(line, sizeof(line), in) != NULL) {
      // do something with line
  }
  </code></pre>
  
  <p>How do I use c++ to avoid having to specify the line size? I.e. be able to handle a line of any length?</p>
  
  <p><strong>Edit, getline doesn't work! :=[[</strong></p>
  
  <pre><code>FILE *in;
  std::string line;
  while(std::getline(in, line))
  {
     // Says no matching function =((((
  }
  </code></pre>