I use Turbo C++. I m studying classic C++.I made the follwing program to calculate the occurance of the Word He in the File STORY.TXT. But I feel my Bold Part of the program is wrong. How can i obtain a string using (first using getline() then using get) function and compare it??I dont want to use strcmp() function...
line 23: line == He checks if the whole line says He, you want to check if it the word He simply shows up in this line. since you dont want to use string-compare, you have to use a loop. run through all the characters in line and see if there is a "H". if that's the case, check if the next character is "e" and you're done.
ANd you shouldnt use == with c-strings. Use strcmp() from <cstring> or think about using std::string from <string> which come with neat member function and support for most operators.