title: Downloading a file from URL to disk in C++
body: <p>I have a simple question.  Is it possible to write simple code to download a file from the internet (from URL to disk) without using C++ (for mac osx) libraries like curl?
  I have seen some examples but all of these use the Curl library.</p>
  
  <p>i use this code on my xcode projet..but i have some compilation (linking) errors</p>
  
  <pre><code>    #define CURL_STATICLIB
  #include &lt;stdio.h&gt;
  #include &lt;curl/curl.h&gt;
  #include &lt;curl/types.h&gt;
  #include &lt;curl/easy.h&gt;
  #include &lt;string&gt;
  
  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 main(void) {
      CURL *curl;
      FILE *fp;
      CURLcode res;
      char *url = "http://localhost/aaa.txt";
      char outfilename[FILENAME_MAX] = "bbb.txt";
      curl = curl_easy_init();
      if (curl) {
          fp = fopen(outfilename,"wb");
          curl_easy_setopt(curl, CURLOPT_URL, url);
          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>how can i link the curl library to my xcode project?</p>