/Why i can't match the input with the constant string array?
It always shows the record with -1
Thank you./
#include<iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <string>
#include <windows.h>
#include <cmath>
string stuname[3]={"Chan Tai Man, Peter","Ng Fat Tat", "Tsang Chi Wai"};
void searchStudent(){
string search;
int record=-1;
cout<<"Enter Student ID or Student Name: ";
cin>> search;
for(int i=0; i<3; i++)
{
if(search==stuname[i])
record=i;
}
cout<< record <<endl;
}
int main(){
searchStudent();
return 0;
}