c++ - Comparison of string with the File data -


i m stuck in simple problem ,this code part of programme takes data user , reads data file(that contains name of movies , actors) , compare input gives wrong result.this code

#include<iostream> #include<fstream> using namespace std; int main() {     string name;     getline(cin, name);     string compare;     ifstream myfile;     myfile.open("movie.txt");     bool found = false;     if (myfile.is_open())     {         while (getline(myfile, compare))         {             if (compare == name)             {                 cout << "record found" << endl;                 found = true;             }         }         myfile.close();     }     if (found)         cout << "not found" << endl; } 

any regarding appreciated . thanks

for debug can use string_to_hex here on both compare , name


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -