In K&R Chapter 1.9, I\'ve been experimenting with the program provided below. Particularly, what would happen if I removed certain decelerations of functions.
So
To add a function you need to give a prototype for it. Thats what this is
void copy(char to[], char from[]);
But if you don't provide the prototype, the return type of the function is taken as int
by default.
This is the reason why it is working for the function getfatline()
, because its return type is int
when you are using it later in the code, which is the same as taken by default when you remove the prototype.
But when you remove the prototype for the function copy
, the return type is set to int
by default but your function definition has the return type as void
, that is where the conflict is occurring, and it is throwing an error.