Originariamente inviato da Salvatore_91
a me invece non e' cosi.
Anche con il tuo programma la if non viene verificata.
Con le correzioni in rosso dovrebbe funzionare ...
codice:
void CancellazioneLogica(string NomeFile)
{
string id,IDcanc,riga;
bool trova=false;
cout << "Inserisci l'ID del record da cancellare = ";
cin >> IDcanc;
IDcanc.resize(5, ' ');
fstream file(NomeFile.c_str(),ios::in | ios::out);
while(!file.eof())
{
getline(file,id,';');
id.resize(5, ' ');
cout << IDcanc <<"."<< endl;
cout << id << "."<< endl;
if (id==IDcanc)
{
file.seekp(file.ftell(), ios::beg);
file <<"X";
cout << "Cancellazione Logica effettuata "<< endl;
trova=true;
}
getline(file,riga,'\n');
getchar();
}
if (trova==false)
cout << "ID inserito: "<<IDcanc<<" non trovato!" << endl;
else
cout << "ID trovato" << endl;
file.close();
}