In chapter 6.3 of K&R the function getword() is defined like this:
int getword(char *word, int lim)
{
int c, getch(void);
void ungetch(int);
char *w = words;
while(isspace(c=getch()))
;
if(c!= EOF)
*w++; = c;
if(isalpha(c)) {
*w = '\0';
return c;
}
for(;--lim > 0; w++)
if(!isalnum(*w)getch()){
ungetch(*w);
break;
}
*w = '\0';
return word[0];
}
I don't understand the syntax of the line
int c, getch(void);
it is the first time I'm seeing this. Why is it declaring a function as int? Shouldn't be enough to insert prototypes of functions before calling them?