0

Hi!

I'm trying to implement the easy curl function to get a website, curl_easy_setopt(curl, CURLOPT_URL, m_sURL);, where the third argument is the only one that i give, and it's in this part of the code:

...
public:
    string m_sURL;
    URL() : m_sURL("http://www.google.com") {   }
    ...

Now, when I call curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com"); everything works fine. But if instead, I want to dynamically submit my own URL with m_sURL like this: curl_easy_setopt(curl, CURLOPT_URL, m_sURL);, doesn't work.

I'm using cout << endl << "Usando: " << m_sURL << endl; right before calling curl_easy_setopt... and it looks like it's what it should be, but cURL says it can't resolve the hostname. So there must be some hidden character I can't see in m_sURL?

Thanks.

Edited by neithan

4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by sftranna
0

A string is not exactly the same as a character array. There's a bit of overhead that goes into it.
Try using

 curl_easy_setopt(curl, CURLOPT_URL, m_sURL.c_str());
0

It works now with c_str().

Why exactly wasn't working before?

Thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.