Count keywords in a file
<p>I'm working on a program, that would load itself's .cpp file and find a number of specified keywords. The problem is, I don't know how to recognize a word in string if the string is longer.
The concrete example: 
We are looking for an int, but what if there's function that's written:</p>

<pre><code>int main(int argc, char* argv[])
</code></pre>

<p>? If I load it in as a strings, it's gonna be s1 = "int", s2 = "main(int" and so on, but then when I compare keywordInt = "int" and s2 = "main(int", they are not equal. I tried string::find function, but then, someone could write a code "int countSheep(int,int)" and again it would find only one int.</p>

<p>Can you help me?</p>

<p>UPDATE: Uhm, I feel pretty stupid, but please... I kinda can't find or understand any of those lexers/parsers/syntax highlighters... and I kinda don't even know what to look for. I tried to find some class that someone has done that would do the job - tokenize the strings and recognize what kind is it, but I'm still failing. Could you give me another lead, please?</p>
