Barry Schwarz napisa³(a):
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
Here you call curl_easy_setopt and the third argument is a function
pointer. This is completely inconsistent unless curl_easy_setopt is a
variadic function. Is it?
I don't know if I understand you correctly, because I haven't heard
about variadic functions before. There's a paragraph in libcurl which says:
"Let's assume for a while that you want to receive data as the URL
identifies a remote resource you want to get here. Since you write a
sort of application that needs this transfer, I assume that you would
like to get the data passed to you directly instead of simply getting it
passed to stdout. So, you write your own function that matches this
prototype:
size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
You tell libcurl to pass all data to this function by issuing a function
similar to this:
curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, write_data); "
Userp can be FILE, but I wanted it to be a variable.
curl_easy_setopt(curl, CURLOPT_WRITEDATA, tablica);
I'm passing tablica to write_data, because I want all that is downloaded
by curl to be stored in this variable. I still have a lot to read about
local and global variables, so it might be not that necessary as I
think. Please tell me if there's any better solution to do what I want
to do.
I'm not getting any errors anymore. Unfortunately I only found a
temporary solution.
char tablica[100000];
tablica[0] = '\0';
I'm so used to PHP and not being forced to worry about memory
management:( Is it possible to change variables size at runtime? Because
I never know how big a webpage will be. E.g. I declare an empty
variable, read the buffer, see that it is currently e.g. 1000bytes long,
so I make my variable 1000bytes long, then I read buffer again and I see
than now it's 2000bytes long, so I add another 2000 bytes to my variable
(to make it 3000 bytes long), and so on and so forth. How do I do that?
Best regards,
Jacek