cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Curl Multi Problem.

From: Richard Atterer <richard_at_2007.atterer.net>
Date: Mon, 6 Aug 2007 12:28:08 +0200

On Mon, Aug 06, 2007 at 03:41:05PM +0530, Surya Kiran Gullapalli wrote:
> Does that mean, I cannot use std::string or std:stringstream at all?

No, you can use it.

> If the answer is no, then how can i modify my program ?

Introduce a string variable which will remain instantiated throughout the
lifetime of the curl request. In your simple example, the following will
probably work:

ostringstream os ;
os << "http://curl.haxx.se" ;
string url = os.str();
curl_easy_setopt(http_handle, CURLOPT_URL, url.c_str()) ;

> I do not know upfront, how many web pages i wanted to download. That will
> be decided at run time and I want to use vector<string> for this.

Um, yes... but C++ is an object-oriented language, it might be cleaner to
encapsulate both the std::string and the other curl data structures into a
C++ object. (Maybe also have a look at <http://curl.haxx.se/libcurl/cplusplus/>.)

Cheers,

  Richard

-- 
  __   _
  |_) /|  Richard Atterer     |  GnuPG key: 888354F7
  | \/|  http://atterer.net  |  08A9 7B7D 3D13 3EF2 3D25  D157 79E6 F6DC 8883 54F7
   '` 
Received on 2007-08-06