プログラムで何かをすることに問題があります。人の名前を保持する char[28] 配列があります。名前も保持する別の char[28] 配列があります。最初の配列の名前を入力するようにユーザーに依頼すると、2 番目の配列はバイナリ ファイルから名前を読み取ります。次に、それらを == 演算子で比較しますが、名前は同じでも、デバッグすると値が異なって見えます。これはなぜですか?これら2つを比較するにはどうすればよいですか?私のサンプルコードは次のとおりです。
int main()
{
char sName[28];
cin>>sName; //Get the name of the student to be searched
/// Reading the tables
ifstream in("students.bin", ios::in | ios::binary);
student Student; //This is a struct
while (in.read((char*) &Student, sizeof(student)))
{
if(sName==Student.name)//Student.name is also a char[28]
{
cout<<"found"<<endl;
break;
}
}