You have
stud.write((char *)&s.id, sizeof(short);
stud << s.id;
That writes the student id to the file twice, once as a binary number, and once as an text string. So I don't think your data file ends up with the data you think it does.
You also have a data mismatch here: you're only writing 2 bytes from student::id, not all four. This means if the student ID is greater than 65535, you will only write out the bottom four bytes.
You can simplify things greatly by just writing the student struct as a binary blob
stud.write( (char *)&s, sizeof s);
This will write the entire structure out in one go. No need to write the elements individually.
The search then becomes
student s;
bool found = false;
ifstream stud("sd.txt", ios::binary);
while( !found )
{
stud.read((char *)&s, sizeof s);
if( stud.eof() ) break;
if(s.id = item)
{
found = true;
}
}
if( !found )
{
}
If you do write your student data as a single binary blob, you don't have issues updating. If you change a name from say, "J. Smith", to "James Smith", in your current schema, you'll have to read in all records after "J. Smith"'s, write out the updated "Jame Smith" record, then write out all the successive student records. As a binary blob, though, all you need to do update the student struct, and write it out in the correct location. The output will always be 80 bytes, regardless of the struct's contents.