Napisałem program który pobiera z mojej strony z pliku file.txt treść (jest to tylko 0 i 1) noi pytanie czy ktoś mógłby przerobić kod tak aby treść zapisywała się do stringu "url" ponieważ narazie nie działa mi "if" ;/
Kod: Zaznacz cały
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <winable.h>
#include <conio.h>
#include <curl/curl.h>
#include <curl/easy.h>
#include <string>
#include <sstream>
int main()
{
std::cout << "Program się uruchomił !" << std::endl;
while(true)
{
CURL * curl;
curl = curl_easy_init();
curl_easy_setopt(curl,CURLOPT_URL, "http://nick:haslo@www.tomass.net/pliki/file.txt");
string url;
curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE, url.c_str()); //pobieramy kod zrodlowy
curl_easy_perform(curl); //pokazuje treść strony
curl_easy_cleanup(curl);
cout << url << endl; //pokazuje pusty string
if(url == "1")
{
std::cout << "ON" << std::endl;
}
if(url == "0")
{
std::cout << "OFF" << std::endl;
}
Sleep(2000);
}
_getch();
return 0;
}
@EDIT
Dobra już zrobiłem.