#include <stdio.h>
char toUpper(char);
int main(void)
{
char ch, ch2;
printf("lowercase input : ");
ch = getchar();
ch2 = toUpper(ch);
printf("%c ==> %c
", ch, ch2);
return 0;
}
char toUpper(char c)
{
if(c>='a'&&c<='z')
c = c - 32;
}
In toUpper function, return type is char, but there is no "return" in toUpper(). And compile the source code with gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4), fedora-14.
Of course, warning is issued: "warning: control reaches end of non-void function", but, working well.
What has happened in that code during compile with gcc?
I want to get a solid answer in this case.
Thanks :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…