New Feature:
int getNonBlankLine(char str[])
{
int nb = 0;
while (nb == 0)
{
int i = 0;
int c;
while (i < N - 1 && (c = getchar()) != EOF && c != '\n')
{
str[i++] = c;
if (!isblank(c))
nb++;
}
}
if (c == EOF)
return 0;
str[i] = '\0';
return i;
}
This returns the length of the string; it excludes a new line from the returned data; it skips all empty lines; it does not overflow its buffer; it does not give you the opportunity to detect that the string does not all fit into the buffer.
, . , .
isblank(), , isspace(), , , , , (" \t\n\f\r\v").