I am using libcurl to make request google server. The curl library is giving output , when i use curl variables as global every thing works fine but when i am using the curl variables as local inside a function or a class private members the program crashes. I am not able to catch where segmentation fault occurring.
Code is
void func1();
{
Internet_connection_through_curl internet_connection;
internet_connection.simple_program(query_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);
}
}