Duplicate: Alternative (K&R) C syntax for function declaration versus prototypes
I have some homework I need to do (in C) and in this homework we're given some method stubs. I'm not very good in C, but when I looked at the stubs this caught my eye:
...
A_output(message)
struct msg message;
{
}
A_input(packet)
struct pkt packet;
{
}
...
Namely, the definition of both msg
and pkt
between the function's name/parameter and definition. Both the message
and packet
parameters are to be structs; their respective member declarations are above their first uses, towards the beginning of the .c file:
struct msg {
char data[20];
};
struct pkt {
int seqnum;
int acknum;
int checksum;
char payload[20];
};
Is this kind of initialization some sort of C syntax I'm not familiar with or just a typo? I looked around but couldn't find anything like this, nor have I ever seen anything like it in any other language, to split up a function's code like that. The compiler is screaming about invalid function prototyping no matter what I do so something seems amiss...