Ciao,
ho questo codice:
Codice:
int main(int arcg, char* argv[])
{
{
// Open input file stream
ifstream ifs("Test Element.txt");
if (!ifs)
throw runtime_error("Couldn't open the input file!");
// Find the beginning of the Element Data section
string line;
while (getline(ifs, line, '\n'), line != "$* ELEMENT DATA")
{
if (ifs.eof())
{
cout << "Cannot find Species Data!!" << endl;
return 0;
}
}
// Save the beginning of the Element Data section
streampos begin = ifs.tellg();
}
}
con questo file di testo:
Codice:
!File di prova per testare la routine di gestione degli elementi
$* ELEMENT DATA
C .1201070000D+02 CO2 CO2 .3700000000D-03
H .1007940000D+01 H2O H2O .0000000000D+00
N .1400670000D+02 N2 N2 .7809000000D+00
O .1599940000D+02 O2 O2 .2095000000D+00
$* END OF ELEMENT DATA
Ebbene, se eseguo il tutto in VS 2012, begin ha valore 85, mentre se uso QtCreator con MinGW (4.7, o 4.8, non cambia) ha valore 94, che è ERRATO!
Infatti se poi faccio ifs.seekg(begin) e uso getline, in VS ottengo la linea intera
Codice:
C .1201070000D+02 CO2 CO2 .3700000000D-03
mentre con MinGW ottengo
Codice:
70000D+02 CO2 CO2 .3700000000D-03
e non capisco davvero perchè! Mi sfugge qualcosa o è un baco?