[英]My libcurl based program doesn't work from the point of the first “curl_easy_setopt” and returns 0xC0000374
我從 libcurl 下載文件,將某些文件移動到 MINGW 中的文件夾,在鏈接器設置中添加 curl(我有代碼塊)並編寫了這個程序。 不知何故,它在res = curl_easy_setopt(curl1, CURLOPT_URL, url.c_str());
行停止並返回代碼 -1073740940 (0xC0000374 res = curl_easy_setopt(curl1, CURLOPT_URL, url.c_str());
我正在測試的整個代碼部分如下所示:
string html_to_string (string url)
{
string s;
cout << "chp" << endl;
CURL *curl1;
cout << "chp" << endl;
CURLcode res;
cout << "chp" << endl;
res = curl_easy_setopt(curl1, CURLOPT_URL, url.c_str());
cout << "chp" << endl;
if(res != CURLE_OK)
{
cout << "blad1" << endl;
}
cout << "chp" << endl;
res = curl_easy_setopt(curl1, CURLOPT_WRITEDATA, &s);
if(res != CURLE_OK)
{
cout << "blad2" << endl;
}
cout << "chp" << endl;
res = curl_easy_perform(curl1);
if(res != CURLE_OK)
{
cout << "blad3" << endl;
}
cout << "chp"<< endl;
return s;
}
int main()
{
string url = "https://om.mimuw.edu.pl/";
string htmlcode = html_to_string (url);
cout << htmlcode;
}
該函數旨在獲取 html 響應並將其放入字符串中以進行進一步更改。 現在我想專注於第一部分並將 html 代碼轉換為字符串。
謝謝大家的評論。 是的。 解決方案是讓CURL *curl1 = curl_easy_init();
行而不是CURL *curl1;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.