Function declaration: K&R vs ANSI

ashna picture ashna · Jun 22, 2010 · Viewed 37k times · Source

What are the differences between a K&R function declaration and an ANSI function declaration?

Answer

Wizard picture Wizard · Jun 22, 2010

K&R syntax is obsolete, you can skip it unless you have to maintain very old code.

// K&R syntax
int foo(a, p) 
    int a; 
    char *p; 
{ 
    return 0; 
}

// ANSI syntax
int foo(int a, char *p) 
{ 
    return 0; 
}