CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2014
    Location
    Las Vegas, NV
    Posts
    85

    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!

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Getting cURL result in MFC C++

    Quote Originally Posted by eclessiastes View Post
    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.

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured