bool BODYTYPE::Seek(BODYTYPE * body)
{
string line;
string key(body->style);
size_t found = ' ';
fstream file("..\\Data\\BODYTYPE.txt",ios::in);
if (!file.is_open())
{
cout << "Unable to open file \n";
return false;
}
file.clear();
file.seekg(0);
for(;getline(file,line);)
{
if((found = line.find(key,0)) == 0 )
{
file >> body->style
>> body->doorCount;
return true;
}
}
if ((found = line.find (key, 0)) != 0 )
cout << "Style " << key << " not found!" << endl;
file.close();
return false;
}
How ever if I have data in a the file:
Pickup 2
4x4 4
Sedan 4
Convertible 2
Hardtop 4
Hatchback 5
Muscle 0
and i try to seek "Hardtop" it retrieve Hatchback.
It is over seeking.
How can I correct this?