it's part of a function that's supposed to do a word search in a binary file.
the first if searches for the singular form of the word. if it doesn't find it goes to second if searches for plural form. again, if it doesn't find it goes to the third if the didyoumean search type. all good.
the problem is that if the first if works it still does the third if . same goes for the second if.
for the first and second if the output should only be the word's translation but i also get the some other words coresponding to the third if.
the first if searches for the singular form of the word. if it doesn't find it goes to second if searches for plural form. again, if it doesn't find it goes to the third if the didyoumean search type. all good.
the problem is that if the first if works it still does the third if . same goes for the second if.
for the first and second if the output should only be the word's translation but i also get the some other words coresponding to the third if.
any ideas?
thanks
Reformat your code, and you will see what you're saying cannot possibly happen:
What doesn't work? The if() statements do "work", in the sense that if the first if() is processed, none of the other conditions are processed.
theoretically it should work .. but it still doesn't .. it has something to do with the strncmp line. i've changed it with something else and it works how it should. how should i write the strncmp line so i don't get this "bug" ?
OP, I hope you can understand how frustrating of a thread this is. Please post a complete example that demonstrates the problem. For all we know the code that you pasted isn't the same as what you are executing. Your description of the original problem makes no sense at all. Paul already pointed that out yet you have not really answered his question. By the way I cannot open the URLs as they are blocked by my company firewall. It is best if you post a program that others can compile and execute on their own in order to duplicate the problem.
Last edited by kempofighter; January 18th, 2010 at 05:19 PM.
In addition to what the other posters have asked for or said, put a couple of break points in each of the if, ifelse, else clauses and step through the code in a debugger.
If you are relying on the console output, then are you sure you aren't confusing the output?
so.. i found out what the real problem is. i thought that after doing first or second if the search jumps to the third if but actualy after doing first or second if it runs the for again, thus doing the third if and i get both solutions. if i added 2-3 more ifs that matched the search_word it would, after every if matb]ched, jump again to the for until there aren't any other ifs matching the search_word.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.