30/09/2018, 19:08
Puzzle: Can we call an undeclared function in C?
Let see the code below.
#include <stdio.h>
int main(void) {
// your code goes here
printf("%d
", func());
return 0;
}
int func() {
return 10;
}
Can we run this code and get no error?
Bài liên quan
I think we can do that by declare a prototype of 'func ’ before main function like this:
is it solution?
First seen, No f way :))
After compiled: ⊙_⊙ Wot? How?
This topic sholve this issue.
GeeksforGeeks – 5 Aug 10
Can we call an undeclared function in C++? - GeeksforGeeks
Calling an undeclared function is poor style in C (See this) and illegal in C++. So is passing arguments to a function using a declaration… Read More »
Conclusion:
In C, we can call an undeclared function, but we can’t do this in C++.
OMG, how stupid i’m
Your answer is true. This is just a trick in C. Don’t worry about that.
I am the same you before found this issue.