1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Dynamically load url in libcurl with C++

Discussion in 'C++' started by thekevin07, Sep 13, 2008.

  1. thekevin07

    thekevin07 New Member

    Joined:
    Sep 13, 2008
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    I am eventually going to call url dynamically from mysql but below is pretty close what i'm trying to do before i plug mysql into my program. The error that gets returned is error code 3
    which i believe means the url was formatted poorly anyone know what im doing wrong

    Code:
    	
    string x="http://www.mysite.com/";
         curl = curl_easy_init();  
     	  curl_easy_setopt(curl, CURLOPT_URL, x);
     

    Thanks
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Not RTFM is what you're doing wrong.

    CURLOPT_URL
    The actual URL to deal with. The parameter should be a char * to a zero terminated string.

    A string is NOT a char * to a zero terminated string. However, x.c_str() is, so that would be the solution.
     
  3. thekevin07

    thekevin07 New Member

    Joined:
    Sep 13, 2008
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    sorry i did read the manual but im kind of new still i took a c++ course in high school a while back im not use to .c_str() type stuff all the work we did dealt with numbers.

    Thank you very much for the help.
     

Share This Page