Variable declaration after function's argument list

This is an old notation known as K & R (Kernighan & Ritchie, after Brian Kernighan and Dennis Ritchie) Notation for declaring the functions. If your compiler supports it, you can use it and it is same as declaring the function with ANSI notation.


As mention by others, this is an early style of function coding.

Following is a pitfall of that style. Be aware there is no type checking on passed parameters. It may explain your run time differences.

Say you declare a function

int foo(a,b,c);

All the compiler sees at that point is a function named "foo" taking 3 arguments and returning an int. Thus usage checking is limited to that.

Let's assume sizeof(short) < sizeof(int) < sizeof(long) and the function is defined as

int foo(a,b,c)
  int a;
  long b;
  int c;
{ /* code body */ }

Notice the following usage of foo

int d,e,f;
d = foo(1,2L,3);
e = foo((short)1,2L,3);
f = foo(1,2,3);

The first usages works fine, the right size integers are passed to foo.
The 2nd usages also works fine. The first argument is promoted to int size before the call, much like printf("%d", (short)2) promotes (short)2 to int before passing to printf().
The 3rd is a problem as the compiler does not know the second argument needs to be long. Thus the data passed to foo is not passed correctly. --> UB


This is an old C syntax. If your compiler can swallow it then it should work the same as if you have declared the functions the normal, ANSI way.