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\n", func());
    return 0;
}

int func()    {
    return 10;
}

Can we run this code and get no error?

I think we can do that by declare a prototype of 'func ’ before main function like this:

int func();

is it solution?

First seen, No f way :))
After compiled: ⊙_⊙ Wot? How?

1 Like

This topic sholve this issue.

Conclusion:
In C, we can call an undeclared function, but we can’t do this in C++.

:dizzy_face: :dizzy_face: :dizzy_face:

2 Likes

3 Likes

OMG, how stupid i’m :kissing:

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.

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?