1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_WRITEDATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_HEADERDATA (3)
9  - CURLOPT_READDATA (3)
10  - CURLOPT_WRITEFUNCTION (3)
11---
12
13# NAME
14
15CURLOPT_WRITEDATA - pointer passed to the write callback
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEDATA, void *pointer);
23~~~
24
25# DESCRIPTION
26
27A data *pointer* to pass to the write callback. If you use the
28CURLOPT_WRITEFUNCTION(3) option, this is the pointer you get in that
29callback's fourth and last argument. If you do not use a write callback, you
30must make *pointer* a 'FILE *' (cast to 'void *') as libcurl passes this
31to *fwrite(3)* when writing data.
32
33The internal CURLOPT_WRITEFUNCTION(3) writes the data to the FILE *
34given with this option, or to stdout if this option has not been set.
35
36If you are using libcurl as a Windows DLL, you **MUST** use a
37CURLOPT_WRITEFUNCTION(3) if you set this option or you might experience
38crashes.
39
40# DEFAULT
41
42By default, this is a FILE * to stdout.
43
44# PROTOCOLS
45
46Used for all protocols.
47
48# EXAMPLE
49
50A common technique is to use the write callback to store the incoming data
51into a dynamically growing allocated buffer, and then this
52CURLOPT_WRITEDATA(3) is used to point to a struct or the buffer to store
53data in. Like in the getinmemory example:
54https://curl.se/libcurl/c/getinmemory.html
55
56# AVAILABILITY
57
58Available in all libcurl versions. This option was formerly known as
59CURLOPT_FILE, the name CURLOPT_WRITEDATA(3) was added in 7.9.7.
60
61# RETURN VALUE
62
63This returns CURLE_OK.
64