#include <curl/curl.h>
#include <iostream>
/****************************************************************/
/*!
* Notifier application for new releases of used libraries
*****************************************************************/
int main(int argc, char**argv){
void *buffer=calloc(20480,1);
size_t readBytes=0;
CURL* request=curl_easy_init();
curl_easy_setopt(request,CURLOPT_URL,"http://icl.cs.utk.edu/projectsfiles/plasma/pubs/ReleaseNotes");
curl_easy_setopt(request, CURLOPT_HEADER, true);
curl_easy_perform(request);
CURLcode result = curl_easy_recv(request,buffer,20480,&readBytes);
if (result==CURLE_OK)
{
std::cout<<buffer<<std::endl;
std::cout<<readBytes<<" bytes received"<<std::endl;
}else
{
std::cout<<"Request failed!"<<std::endl;
}
std::cin>>readBytes;
curl_easy_cleanup(request);
free(buffer);
return 0;
}
It compiles fines, but at runtime, i get in output the first cout of the if block, and the cout of the else statement. How can it not run the complete if block? And run the if AND the else block?
(The downloaded file is smaller than the buffer, in case you ywould suspect a buffer overflow there)
Ah ok hehe, it's my first cURL program
Would you know how to disable the output in the console, and why it says the operation failed even though i see the full content of the file?