Opis problemu w komentarzu kodu.
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <curl/curl.h>
#include<stdlib.h>
using namespace std;
void get_page( const char* url, const char* file_name )
{
CURL* easyhandle = curl_easy_init() ;
curl_easy_setopt( easyhandle, CURLOPT_URL, url ) ;
std::FILE* file = std::fopen( file_name, "w" ) ;
curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file ) ;
curl_easy_perform( easyhandle );
curl_easy_cleanup( easyhandle );
}
int main()
{
ifstream IPlog;
bool good();
string liniaIP,myIP[65000],szukfraza="<ip_address>";
size_t found;
int i=0;
get_page( "http://www.domaintools.com/research/my-ip/myip.xml",
"daneIP.txt" ) ;
IPlog.open( "daneIP.txt");
if( IPlog.good() == true )
{
cout << "Uzyskano dostep do pliku!" <<endl;
while(!IPlog.eof()) {
getline(IPlog,liniaIP);
cout<<liniaIP.length()<<endl; // w tym miejscu sypie się program, program zwraca 0 i wyskakuje "program przestał działać"
found = liniaIP.find(szukfraza);
if (found!=0) {
myIP[i]=liniaIP.substr(found+szukfraza.length(),liniaIP.length()- ((2*szukfraza.length())+1)); //+1 bo końcowy znacznik to </ip_adress>
cout<<myIP[i]<<endl;
}
i++;
}
IPlog.close();
}
else cout << "Brak Dostępu do pliku!" <<endl;
system("pause");
}
Dostęp do pliku działa, pokazuje się komunikat...sprawdzałem to wszystko na zwykłym stringu i działało, niestety w momencie w którym chce czytać z pliku zaczynają się schody.