我正在使用libcurl来发出请求谷歌服务器。 curl库正在给出输出,当我使用curl变量作为全局时,每件事情都运行正常但是当我在函数或类私有成员中使用curl变量作为本地时,程序崩溃。我无法捕捉到segaion故障发生的地方。
代码是
void func1();
{
Internet_connection_through_curl internet_connection;
internet_connection.simple_program(querry_url);
}
Internet_connection_through_curl::simple_program(string url)
{
CURL *curle;
CURLcode rese;
curle = curl_easy_init();
if(curle)
{
curl_easy_setopt(curle, CURLOPT_URL, url.c_str());
curl_easy_setopt(curle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curle, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curle, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curle, CURLOPT_WRITEDATA , (void *)(&UF));
curl_easy_setopt(curle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(curle, CURLOPT_HEADERFUNCTION, HeaderMemoryCallback);
rese = curl_easy_perform(curle);
fprintf(stderr , "Curl easy perform error----> %s\n" , curl_easy_strerror(rese));
if(rese != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(rese));
curl_easy_cleanup(curle);
}
}