It will eat input until the data comes in with at least 2 new lines in a row (or an EOF). After that, unless EOF was reached it will eat newline characters until something other than a newline is reached and then return that character.
From the name of the function, I would assume it is simply skipping all input until it encounters '\n' twice in a row (the end of record marker?) or EOF and then returns the character immediately following the skipped record (or EOF if that was received).
Without more context I don't think we can give you much more info. For example, I don't know why it is given the initial character as a function parameter. Perhaps it is called by something like
Code:
int next_char = skip_record(getchar());
but consider
Code:
int skip_record()
{
int pch = EOF; /* previous char */
int cch = getchar(); /* current char */
while ( (cch!= EOF) && ((cch!='\n') || (pch!='\n')) )
{
pch = cch;
cch = getchar();
}
while (cch=='\n') cch = getchar();
return cch;
}
Since skip_record() doesn't do anything with cch except use it as a control in the while condition, the only reason I can think of to pass cch in rather than do it as my modified function shows is so that the caller can pass EOF to the function to make it basically do nothing.