On Mon, Mar 4, 2013 at 10:27 AM, Jason T. Slack-Moehrle <[email protected]> wrote: > Hello All, > > I am trying to run cURL to a PHP URL and get back a response and write it to > a file or first a string, then a file, which ever works best. > > OSX 10.8, latest cURL. > > I have: > > CURL* curl; > curl_global_init(CURL_GLOBAL_ALL); > curl = curl_easy_init(); > curl_easy_setopt(curl, CURLOPT_URL, jstr.c_str()); > curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_data); > curl_easy_setopt(curl, CURLOPT_WRITEDATA, &stream); > curl_easy_perform(curl); > std::ofstream outFile; > outFile.open(lFileName.c_str()); > if (outFile.good()) > { > outFile << stream.str(); > } > outFile.close(); > curl_easy_cleanup(curl); > curl_global_cleanup(); > > the write_data(): > > size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata) > { > std::ostringstream *stream = (std::ostringstream*)userdata; > size_t count = size * nmemb; > stream->write(ptr, count); > return count; > } > > I seem to be crashing at: stream->write(ptr, count); > > with simply a bus error
A complete (compile-able) standalone program would help avoid this question: Are your write functions by any chance non-static methods in a class? Lars Nilsson ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
