Quote:
when I declared the variable result, is it guaranteed to be equal to zero ?
When you declare it, it's not guaranteed to be anything. You should initialize if you want it to be guaranteed to be equal to something. As far as what it will be when the function returns, well that'll be function specific. Most functions use a returned zero as success, because then they can use the returned number as an enumerator to a list of error codes.
As an example, see how MS treats error codes (0=ERROR_SUCCESS, operation completed successfully):
http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx[
^]
Quote:
Is this a good practice ?
Sure, as long as you know exactly what it is that the function is returning and you're checking the return condition correctly. In your code you're assuming 0 is error state, you'll have to know that to be true for the function you're calling, which as I've mentioned, is opposite of what most people do.