Bill Cunningham said:
§1.9 page 29 has this function.
int getline (char s[], int lim)
Unless I'm missing something here to pass an array shoudn't that first
parameter be char *s ?
It depends on what you mean by "should".
The rest of this thread indicates that you're aware that this:
int getline (char s[], int lim)
and this:
int getline (char *s, int lim)
are equivalent. This is implied by N1370 6.7.6.3 paragraph 7, or by the
corresponding paragraph in earlier versions or drafts of the C standard.
Apparently you were wondering about this as a style issue, though your
original question gave no hint of that (and nobody is going to assume
that you understand the language issue).
Personally, I dislike using array notation for pointer parameters;
in my opinion it obfuscates the fact that the parameter is really
a pointer. But there are sound arguments for using it. If I write:
void func(char *s);
the intent could be either that s points to a single object of type
char, or that s points to the first element of an array of one or
more char elements. Using array notation:
void func(char s[]);
can make it clear to the reader that it's intended to point to the
first element of an array. (I'd rather express this distinction
in a comment rather than using language syntax.) Furthermore, C99
added features that let you express additional information between
the square brackets. This:
void func(char s[42]);
requires s to point to the first element of an array of *at least*
42 elements. (This requirement is imposed on the caller, and it's
not enforced by the compiler; if you violate it, your program's
behavior is undefined.)
The standard itself uses array notation when defining the
two-parameter definition of main:
int main(int argc, char *argv[]) { /* ... */ }
Again, I prefer to write:
int main(int argc, char **argv) { /* ... */ }
It's interesting to note that the standard *doesn't* use array
notation for the <string.h> functions:
size_t strlen(const char *s);
even though s must point to the first element of an array. This is
arguably a slight inconsistency in the standard, but I don't think
it's worth worrying about.