You are not logged in.
Hello, I am fairly new here and new to programming. I am trying to make a program that will ask for a url and store it in a character array and use that variable as the URL for the url argument, in quotations, using libcurl, of course.
curl_easy_setopt(curl, CURLOPT_URL, "<here>");
However, when I do it the way I would with printf()
curl_easy_setopt(curl, CURLOPT_URL, "%c", &...);
it says prg.c:12:53: error: macro "curl_easy_setopt" passed 4 arguments, but takes just 3
Is there a way to do what I am trying to do?
Last edited by fawx (2008-08-20 13:06:24)
Offline
I don't know what u really want to do. And what I found is that there is not an overloaded function like the one you are trying to use, in fact there is no overloaded functions for that one.
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
If you want to pass a URL that dynamically fills the parameter variable you can first create a string and copy the info from another one then concatenate another.
Here is an example that maybe could help you.
char url[128];
char *page = "hello.html";
strcpy( url, "www.google.com" );
strcat( url, page );
for this you must include string.h, then you can use url to send as parameter in your function.
ISC - Ignacio Marmolejo
ArchLinux & GNOME User.
Offline
If you're trying to build strings from user input, you can do strcpy stuff as shown above, or look at sprintf
man sprintf
It behaves like printf, but instead of writing to STDOUT, it will write it to a string. So, you can build your dynamic string that way, and then pass the result as the 3rd parameter to your curl function.
-nogoma
---
Code Happy, Code Ruby!
http://www.last.fm/user/nogoma/
Offline
What lib does strcpy use?
Offline
string.h
ISC - Ignacio Marmolejo
ArchLinux & GNOME User.
Offline