1
0

46_getexample.c 476 B

12345678910111213141516171819202122
  1. #include <curl/curl.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. size_t writefunc(void *ptr, size_t size, size_t nmemb, void *unused)
  5. {
  6. write(STDOUT_FILENO, ptr, size * nmemb);
  7. return size * nmemb;
  8. }
  9. #define URL "http://example.com"
  10. int main()
  11. {
  12. printf("Loading " URL "\n");
  13. CURL *curl = curl_easy_init();
  14. curl_easy_setopt(curl, CURLOPT_URL, URL);
  15. curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
  16. curl_easy_perform(curl);
  17. curl_easy_cleanup(curl);
  18. return 0;
  19. }