Witam.
Mam funkcję, która pobiera strone internetową do pliku :
void wwwToFile(char * wwwAdres, char * fileName) {
static const char *pagefilename = fileName;
FILE *pagefile;
CURL *curl_handle;
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init(); /* init the curl session */
curl_easy_setopt(curl_handle, CURLOPT_URL, wwwAdres); /* set URL to get here */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data_toFile); /* send all data to this function */
pagefile = fopen(pagefilename, "wb"); /* open the file */
if (pagefile) {
curl_easy_setopt(curl_handle, CURLOPT_FILE, pagefile); /* write the page body to this file handle. CURLOPT_FILE is also known as
CURLOPT_WRITEDATA*/
curl_easy_perform(curl_handle); /* get it! */
fclose(pagefile); /* close the header file */
}
curl_easy_cleanup(curl_handle); /* cleanup curl stuff */
}
Chciałbym ją wywołac w ten sposób :
struct wwwDownload{
std::string bankName;
std::string wwwAdres;
std::string fileName;
};
int main(void) {
wwwDownload www[2] = {
{"NBP","http://nbp.pl/kursy/kursyc.html","NBP.txt"},
{"WBK","http://indywidualni.bzwbk.pl/przewodniki/kursy-walut/kursy-walut-bank-zachodni-wbk-przewodnik.html","WBK.txt"},
};
//Tak było wczesniej -> char adres[] = "http://nbp.pl/kursy/kursyc.html";
// -> char nazwa_pliku[] = "strona.txt";
char adres[] = www[0].wwwAdres; // <- A tak bym chciał wywołać teraz
char nazwa_pliku[] = www[0].fileName; // <-
wwwToFile (adres, nazwa_pliku);
Ale nie moge przypisać stringa do char[] , jak to ominąć ?
probowalem tez
char nazwa_pliku[] = www[0].fileName.c_str
Ale tez nie przechodzi. Może ktoś pomóc ?