64,645
社区成员
发帖
与我相关
我的任务
分享
printf("We received Content-Type: %s\n", ct);
/*
* NAME curl_easy_strerror()
*
* DESCRIPTION
*
* The curl_easy_strerror function may be used to turn a CURLcode value
* into the equivalent human readable error string. This is useful
* for printing meaningful error messages.
*/
CURL_EXTERN const char *curl_easy_strerror(CURLcode);
curl_easy_strerror
这个可以根据CURLcode返回中文
#include <stdio.h>
#include "curl/curl.h"
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/");
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
char *ct;
/* ask for the content-type */
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if((CURLE_OK == res) && ct)
printf("We received Content-Type: %s\n", ct);
}
else
{
printf("Result = %d", res);
}
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
typedef enum {
CURLE_OK = 0,
CURLE_UNSUPPORTED_PROTOCOL, /* 1 */
// 此处省略N个字
CURL_LAST /* never use! */
} CURLcode;
CURLcode 是枚举类型,不能直接转为string