1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <curl/curl.h>
#include <curl/easy.h>
#define FURL "http://www.developpez.net/forums/f897/c-cpp/c/debuter/"
int main(int argc,char *argv[])
{
int rc;
CURL *curlhdc;
long lcode;
FILE *st;
st=fopen("a.txt","w");
if(st==NULL) {printf("st est NULL\n"); exit(0);}
curlhdc=curl_easy_init();
rc=curl_easy_setopt(curlhdc,CURLOPT_STDERR,st);
printf("rc=%d (%s) for stderr=st\n",rc,curl_easy_strerror(rc));
rc=curl_easy_setopt(curlhdc,CURLOPT_URL,FURL);
printf("rc=%d (%s) for url=%s\n",rc,curl_easy_strerror(rc),FURL);
......
rc=curl_easy_perform(curlhdc);
printf("rc=%d (%s) for curl_easy_perform\n",rc,curl_easy_strerror(rc));
rc=curl_easy_getinfo(curlhdc,CURLINFO_RESPONSE_CODE,&lcode);
printf("rc=%d (%s) for response_code\nlcode=%ld",rc,curl_easy_strerror(rc),lcode);
curl_easy_cleanup(curlhdc);
fclose(st);
return(rc);
} |
Partager