So I was making a simple cURL program to retrieve a string from a website. But, when I compile the program, the program returned this error: [Error] Id returned 5 exit status. I've included the cURL library in the project (libcurl.dll). Do you know how to fix this error? :/
Here's the code:
Code:
using namespace std;
#include <iostream>
#include <string>
#include "curl.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
int main(int argc, char** argv) {
CURL *curl;
CURLcode res;
string readBuffer;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "icanhazip.com");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
cout << readBuffer << endl;
return 0;
}
}