What's going on with this code? Are you having a compiler error or is this just if you want to know if it will work well (as in little overhead, etc.)?
I want to find a word in the text file.
but I dont know how to write the code
How can I use the function strcmp()
to compare the word I input with the word in "myfile.text"?
And check the word is it exist or not in the text file
For example,
If "kelvin" "tom" are in "myfile.txt" ,
After I input kelvin,
the program prints the message "You find the word"
You might also consider using std::string, which provides string::compare()/operator== to do the same as strcmp and string::find() do do the same as strstr(). http://www.cplusplus.com/reference/string/string/
thank you
But I still have some questions about the use of strcmp().
Can I use the strcmp() to see if two strings match
while one is input by the user and the other one is in the text file?
If it is possible ,how can i perform it?