I've had a look at your code and I've noticed these two lines:
Code:
id = id.substr(2,8);
and
Code:
string id_line = line.substr(1,8);
Just out of curiousity, why are you 'clipping' these strings?
This is a minor note but instead of doing this:
it may be better if you did something like this:
Code:
if( !id.compare(id_line) )
Also, in your if statement you set the value of 'cleared' to true and then print out a statement based on the value of 'cleared'. Why not just print the statement from your if statement?
Edit: I just realised that I was reading rodrigorules's code instead, but your program works in a very similar way.
Why do you print out a statement saying a patron has towel service in the while loop but then you have this if statement afterwards which seems a bit out of place. The only way this if statement will be true is if no one has towel service because in your while loop you change the value of x to '1' if someone has it, but you don't take it back down afterwards, and even if you did set it to '0' when someone didn't have it, it wouldn't print out the message because your if statement is after the loop.
Code:
if (x==0)
{
cout<<"Patron does not have towel service"<<endl;
}
Also, change this line:
to:
I'm also not sure what the point of this is:
Code:
string id1="%130360765";
string id2="U30360765";
string id="aaaaaaaaaaaa";
string id3="aaaaaaaaaaaa";
Why do you initially set them to some stuff if you don't do anything with them? It really makes very little difference to the program, so maybe I'm just being pedantic. Are they relics from your initial version of the code?