title: Problem using libcurl: it does not appear to get the entire page
body: <p>I am having difficulty getting started with libcurl. The code below does not appear to retrieve the entire page from the specified URL. Where am I going wrong?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  #include &lt;curl/curl.h&gt;
  #include &lt;curl/types.h&gt;
  #include &lt;curl/easy.h&gt;
  
  using namespace std;
  
  char buffer[1024];
  
  size_t tobuffer(char *ptr, size_t size, size_t nmemb, void *stream)
  {
      strncpy(buffer,ptr,size*nmemb);
      return size*nmemb;
  }
  
  int main() {
      CURL *curl;
      CURLcode res;
  
  
      curl = curl_easy_init();
      if(curl) {
          curl_easy_setopt(curl, CURLOPT_URL, "http://google.co.in");
          curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,1);
          curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &amp;tobuffer);
  
          res = curl_easy_perform(curl);
  
          printf("%s",buffer);
  
          curl_easy_cleanup(curl);
      }
      return 0;
  }
  </code></pre>