Xcode配置:
Project > Target > Build Phases > Link Binarry With Libraries > + > search libcurl.4.tbd > Add
代码:
#include
#include
int main(int argc, const char * argv[]) {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl){
curl_easy_setopt(curl, CURLOPT_URL, "https://www.baidu.com");
res = curl_easy_perform(curl);
if(CURLE_OK == res){
char *ct;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if((CURLE_OK ==res) && ct);
// printf("Content-Type: %s", CURLE_OK);
}
curl_easy_cleanup(curl);
}
return 0;
}