C

Asked • 06/10/19

Why does a function with no parameters (compared to the actual function definition) compile?

I've just come across someone's C code that I'm confused as to why it is compiling. There are two points I don't understand.First, the function prototype has no parameters compared to the actual function definition. Second, the parameter in the function definition does not have a type. #include <stdio.h> int func(); int func(param) {  return param; } int main() {  int bla = func(10);  printf("%d", bla); }Why does this work? I have tested it in a couple of compilers, and it works fine.

1 Expert Answer

By:

Patrick B. answered • 06/11/19

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.