title: Simple way to download a file with cURL
body: <p>In my program, I want to download a few files. So I took cURL and used this code (taken and modified a little bit from here <a href="https://stackoverflow.com/questions/1636333/download-file-using-libcurl-in-c-c">Download file using libcurl in C/C++</a>):</p>
  
  <pre><code>#include "curl.h"
  using namespace std;
  
  size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
      size_t written;
      written = fwrite(ptr, size, nmemb, stream);
      return written;
  }
  
  int DlZip(){
      CURL *curl;
      FILE *fp;
      CURLcode res;
      string url = "http://wordpress.org/extend/plugins/about/readme.txt";
      char outfilename[FILENAME_MAX] = "/Users/Me/Desktop/bbb.txt";
      curl = curl_easy_init();
      if (curl) {
          fp = fopen(outfilename,"wb");
          curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
          curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
          curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
          res = curl_easy_perform(curl);
          curl_easy_cleanup(curl);
          fclose(fp);
      }
      return 0;
  }
  </code></pre>
  
  <p>But nothing happened and there weren't any file on my desktop :-/</p>
  
  <p>What is the problem with my code?
  Or if you have a simple function to use, could you give me ?</p>
  
  <p>Thanks!</p>