Anybody knows why is this compiling successfully?
c
Solution
Turn up the warning level in your compiler and you should get 2 warnings,
`display` not declared, `int` assumed
and
`display` redeclared
Edit:
Older versions of C (pre C99) aren't really that bothered about return types or argument types. You could say it's part of the K&R legacy. For instance, if you don't explicitly specify the argument types, the compiler won't check them at all.
C++ is stricter, which IMO is a good thing. I always provide declarations and always specify the argument lists when I code in C.
Problem
Anybody knows why is this compiling successfully in C? ``` int main(){ display(); return 0; } void display(){ printf("Why am I compiling successfully?"); } ``` I thought when declaration is not provided C assume `extern int Function_name(arg1,arg2,...){}.` Thus this should give an error but however it's working! I know that Ideone is supressing the warnings but my question is why is it just not giving a straight error? (however in C++ it's straight error)