c++ - 使用 ofstream 时,我应该将什么作为 curl_easy_setopt 中的第三个参数传递?

标签 c++ file-io libcurl ofstream

一切正常

FILE *outfile = fopen(resultPath.c_str(), "w");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);

但我不想使用 fopen(),因为我在其余代码中使用了 ofstream。 所以我尝试了这个:

ofstream outfile;
outfile.open(resultPath.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile.beg);

不知道第三个参数是否正确,编译的时候没有报错,但是写的时候程序崩溃了。 那么执行此操作的正确方法是什么?

最佳答案

That parameter can be a long, a function pointer, an object pointer or a curl_off_t, depending on what the specific option expects.

关于c++ - 使用 ofstream 时,我应该将什么作为 curl_easy_setopt 中的第三个参数传递?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17993939/

相关文章:

C fopen调用变量名?

java - 如何将输出写入文本文件,与 show() 函数显示的输出相同

c - 无法在 C 中编译 libcurl 程序

linux - 如何让 libcurl 只安装共享库

c++ - fopen 产生 NULL 文件指针 Solaris

c++ - 弃用 std::allocator<void>

c++ - 使用智能指针将派生类的实例存储在 vector 中

c++ - 无法在带有 conan 的 cmake 中找到请求的 Boost 库

c++ - 如何在 C++ 中打印 Unicode 字符?

java - 如何读取文件,然后将每个文件整数分配给数组列表?