Please don't ask us to do your homework. If you have tried, then show your code and we'll help.
I'll give a clue:
first create a file with some text(remember to use "the").
second, open it using an ofstream or ostream object.
third, use get() get the contents of the file byte by byte.
fourth, compare the obtained values with 't', 'h' and 'e' one by one in a if statements.
Please be more specific as to what you are having difficulties with. Is it opening the file, counting the words? Do you have any code so far?
If you need help getting started:
You need to create a string which will temporarily hold the words of the file as well as a counter variable. Then, open the file and read word for word into the temporary string until the end of the file. While doing so, check if the word is "the" and if so, increment the counter.
That actually holds a lot of hints in there. Please do let us know if you require any further help.
Edit: Using std::ifstream::operator>>() you can read in word for word, rather than byte for byte as The illusionist mirage suggested.
as u know i can't copy from my program itself and i need to copy from notepad but even i am not able to get the notepad file . if u can solve this out i will show my code
which probably is reading a whole string rather than just "THE". SO s is not a word but a whole string and a total string with other words is no equal to "THE". Maybe there's the issue.
If you haven't noticed, this guy has the return type of main as void, which suggests he isn't ANSI compatible, so he can't use std::string(he maybe still using Turbo or Borland).
If he can't use std::string, why is he including <string.h>?
Not because of his own implementation of c-strings, because he used a regular one as far as I could tell.