Originally Posted by
Elysia
Both examples are correct. Is it not working in some way? Did you try it?
Ah, so it does. Sorry. What I did was shorten the C file, to show an example of what I was doing. The original file don't work.
Here is what I was trying to do.
Code:
#include <stdio.h>
#include <curl/curl.h>
#include <string.h>
size_t write_data(char *ptr, size_t size, size_t nmemb, char buffer[]) {
strcpy(buffer, ptr);
printf("%s", buffer); // Should print out the HTML source
return (size * nmemb);
}
int main(int argc, char *argv[]) {
char *username = argv[1];
char *password = argv[2];
char *url = argv[3];
int startRange = atoi(argv[4]);
int endRange = atoi(argv[5]);
char buffer[1000];
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_REFERER, "http://www.yahoo.com");
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION , &write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
printf("%s", buffer); // Should hold the HTML source
return 0;
}