I’m pretty new to C, I’ve been studying someone else’s code and I’ve found this function:
static
cp_file(output, input, record, ft)
dy_char *output; /* output file */
dy_char *input; /* input file */
dy_char *record; /* record id */
int ft; /* file type */
{
Does this do exactly the same thing as saying this:
static cp_file(dy_char *output, dy_char *input, dy_char *record, int ft) {
Is one more efficient than the other, or is it purely a different style of syntax? If they are different, what are the differences?
No, they are not identical.
The first form is the old-style function definition and the second is the prototype form of function definition.
They differ with respect to the argument passing conversion. Functions with prototype convert arguments as if by assignment while non-prototype functions like in your first example perform default argument promotion.
Arguments conversion for the old form:
Arguments conversion for the prototype form:
Note that the old form (non-prototype) is obsolescent and is strongly discouraged.