#include
char toUpper(char);
int main(void)
{
char ch, ch2;
printf(\"lowercase input : \");
ch = getchar();
ch2 = toUpper(ch);
You should keep in mind that such code may crash depending on compiler. For example, clang generates ud2 instruction at the end of such function and your app will crash at run-time.
One missing thing that's important to understand is that it's rarely a diagnosable error to omit a return statement. Consider this function:
int f(int x)
{
if (x!=42) return x*x;
}
As long as you never call it with an argument of 42, a program containing this function is perfectly valid C and does not invoke any undefined behavior, despite the fact that it would invoke UB if you called f(42)
and subsequently attempted to use the return value.
As such, while it's possible for a compiler to provide warning heuristics for missing return statements, it's impossible to do so without false positives or false negatives. This is a consequence of the impossibility of solving the halting problem.