For some odd reason I was copying an example in another language of which does not use types, and forgot to add one in to a function definition parameter, and it worked.
#include <stdio.h>
char toChar(n) {
//sizeof n is 4 on my 32 bit system
const char *alpha = "0123456789ABCDEF";
return alpha[n];
}
int main() {
putchar(toChar(15)); //i.e.
return 0;
}
I am sure that main defaults to int by most compilers of some standard (but only return), is this also a behaviour true for other functions as well or is this implementation defined? It seems just out of the ordinary, my compiler is just a slightly outdated GCC port (MinGW).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…