Hi, I'm new to C++ (and to programming for that matter) I need help on how to check if certain words or numbers are present in a text file. for example: (is the number 255 in the text file?) True or False. thanks!
It's not difficult, but we're not going to write the code for you. How far have you got and where are you stuck?
I think yoy should read the value from the file Code: int main () { string line; ifstream myfile ("example.txt"); if (myfile.is_open()) { while (! myfile.eof() ) { getline (myfile,line); cout << line << endl; } myfile.close(); } if(line==value) //value that you want to compare else cout << "Unable to open file"; return 0; }