0

The following compiles and runs and returns 3 on gcc linux x64.

int f();
int main()
{
  return f(1,2,3);
}
int f(int a,int b)
{
  return a+b;
}

Why is it useful to declare a function as int f(); and later define parameters in the function's definition as in this example?

effbiae
  • 1,087
  • 1
  • 7
  • 22
  • 6
    [Because history](https://stackoverflow.com/a/22074190). – Siguza Apr 15 '18 at 22:47
  • You are demonstrating why for the whole of this millennium it has been a very bad idea to use non-prototype function declarations. Time to get a modern compiler and turn on enough warnings that the code shown won’t compile. – Jonathan Leffler Apr 15 '18 at 23:27

0 Answers0