1 karma · joined Jun 30, 2015 (11y ago) · 10 submissions
comment 11y ago · link · parent
C is not a scripting language. If you use the tools available to you, and don't abuse the language, then it is fairly hard to cause undefined behavior.
comment 11y ago · link · parent
The first one enables you to have the function call directly in the if statement, but requires you to define a variable beforehand.
The latter gives you the option to check the return value, pass a NULL, if you don't need it for example, and use the return value directly.
comment 11y ago · link · parent
6.3.2.1,p2 If the lvalue designates an object of automatic storage duration that could have been declared with the register storage class (never had its address taken), and that object is uninitialized (not declared with an initializer and no assignment to it has been performed prior to use), the behavior is undefined.
comment 11y ago · link · parent
If you stick to what is taught in any good tutorial/book, you don't even have to think about problems like this.
But if you decide to play with fire, then you should read the Standard and understand it.