24.05.2017, 06:37
Quote:
It is the same in this case (of course yours isn't wrong, but you don't have to do it, nor is it the solution here). Because any number greater than 0 is considered true, that will make it valid - so any length but 0 will execute the code within the if statement.
This cannot technically be the cause for Warning 225. strlen() returns a value that isn't known at compile time - thus regardless which checks are done the code in brackets can potentially always be executed in a specific case - so it is in theory always reachable. Also the Compiler doesn't know that strlen can only return positive values or zero, so even if you do if(strlen(string) < 0) that warning will not be thrown. |