From what I understand, when parameters are declared in a function like this, a value is passed to them, so they need to be declared somewhere else in order to pass the value to?
In this case, the function is declared and defined at the same time. Pre-ANSI C resolved this. Today, this is considered bad practice. You must add an ad ahead
int getLineLength(char line[], int maxLineLength);
above main , so as not to declare the function implicitly.
If this declaration is missing, the first use of the function becomes its implicit declaration. The compiler accepts the types of parameters of the expression that you pass, and assumes that the function accepts the corresponding types as its parameters. It also assumes that the function returns int . In this case, the compiler has all the information necessary to determine the correct signature, so the function is defined correctly. However, in more complex cases (say, if maxLineLength was declared as long long , not int ), this will lead to undefined behavior, so you should always include a direct declaration of your functions.
source share