Compiler warning – suggest parentheses around assignment used as truth value
Be explicit – then the compiler won’t warn that you perhaps made a mistake. or Some day you’ll be glad the compiler told you, people do make that mistake 😉
Be explicit – then the compiler won’t warn that you perhaps made a mistake. or Some day you’ll be glad the compiler told you, people do make that mistake 😉
According to the standard (§6.4.4.4/10) The value of an integer character constant containing more than one character (e.g., ‘ab’), […] is implementation-defined. This is valid ISO 9899:2011 C. It compiles without warning under gcc with -Wall, and a “multi-character character constant” warning with -pedantic. From Wikipedia: Multi-character constants (e.g. ‘xy’) are valid, although rarely useful …
When using printf, the format string is better be a string literal and not a variable:
You are using a function for which the compiler has not seen a declaration (“prototype“) yet. For example: You need to declare your function before main, like this, either directly or in a header:
The compiler cannot tell from that code if the function will ever reach the end and still return something. To make that clear, replace the last else if(…) with just else.
You are using a function for which the compiler has not seen a declaration (“prototype“) yet. For example: You need to declare your function before main, like this, either directly or in a header:
You are using a function for which the compiler has not seen a declaration (“prototype“) yet. For example: You need to declare your function before main, like this, either directly or in a header: