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
Post a Comment