I am asking user to input a word then have my program compare it with an input .txt file
but even tho I type in exactly a word in data.txt it still executes false.
//------------in my data.txt---------
// Banana Bed Today
// Apples Chair Window
// Corn Tomorrow Hive
string testData;
cout<<"enter Data: ";
cin>>testData;
for(i=0; i<s.size()-1; i++){
if (testData.compare(s[i]->name) == 0)
cout<<"Right\n";
if (youkno.compare(s[i]->name) != 0)
cout<<"Wrong\n";
}
if i prompt Banana then output excuted wrong
If you replace:
with:
you may find it becomes blindingly obvious. There’s a good chance that one of your strings is not quite what you expect.