-
September 27th, 2014, 11:27 AM
#1
Getting cURL result in MFC C++
I'm trying to messagebox the cURL result:
Code:
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
MessageBox(res, _T("Title"), MB_ICONASTERISK | MB_OK);
Is there anyway to messagebox the res value ? Thanks very much!
-
September 27th, 2014, 02:04 PM
#2
Re: Getting cURL result in MFC C++
Originally Posted by eclessiastes
I'm trying to messagebox the cURL result:
Code:
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
MessageBox(res, _T("Title"), MB_ICONASTERISK | MB_OK);
Is there anyway to messagebox the res value ? Thanks very much!
I know nothing about curl, but it took less than 10 seconds to find the answer using Google.
-
September 28th, 2014, 10:38 AM
#3
Re: Getting cURL result in MFC C++
Beside Google/Yahoo/Bing search for an already made solution, a better way is to directly read the documentation.
In this case, for example, can have a look at:
...understand what's there, then put all together and adapt to your needs.
Here is an example that displays a message box containing both returned error code and error description:
Code:
CString strMessage;
strMessage.Format(_T("Error code: %u\nDescription: %hs"), res, curl_easy_strerror(res));
MessageBox(strMessage, _T("Result"), MB_OK);
Note: please don't simply copy-paste it! Try first to understand what's there.
Last edited by ovidiucucu; September 28th, 2014 at 10:42 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|