Remove a line from text file and checks about whitespaces

I have a problem with removing a line from text file. My file is about trains. It contains identificator,number of seats and description about the train. The user inputs ID so i have to find this line with the same ID and remove this line.
this is what i have written:

void trains::deleteTrain()
{
fstream dell("Trains.txt");
if (!dell.is_open())
cout<<"File failed to open!\n";
ofstream temp("temp.txt");

outTrain();
cout<<"Vyvedi identifikatora na vlaka, koito iska6 da iztrie6:\t";
string ID;
cin>>ID;
string line;
while(getline(dell,line))
{
if (ID!=line)
{
temp<<line<<endl;
}
}
dell.close();
temp.close();
remove("Trains.txt");
rename("temp.txt","Trains.txt");
cout<<"\nNalichnite vlakove sa: \n";
outTrain();
}


The other question is about whitespaces. How to do a check in a string?
Example: "ab c" - "abc"
Topic archived. No new replies allowed.