function to log in

hello
my function i send the name and the password to it to check if it in the file student.
if the name and the password are right it should return true and if one of them is false return false but when the function check it always return false and i don't way
can anybody help me

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  bool searchLog(char N[20],char P[20])
{
    ifstream fin;
    fin.open("students.txt",ios::binary);
    while(!fin.eof())
        {
            char buf1[16];
            fin.read((char*) buf1, 16);
            char buf2[16];
            fin.read((char*) buf2, 16);
            if (buf1==N&&buf2==P)
            {
                cout<<"                             Hello "<<N<<endl;
                return true;
            }
      }
    fin.close();
    cout<<"Wrong name or password"<<endl;
    return false;
}
Last edited on
buf1==N is always false. You are comparing pointers here.
Topic archived. No new replies allowed.