You need to specify an empty string.
Also, since "the getline function reads an entire line from the stream, up to the next newline character."
I do not think that
strlen(line) == 1
is portable since Win / DOS and Unix use different conventions for EOL. In addition, EOF can occur before the EOL character is executed. So, really, you need to define a function, maybe something like
int is_blank_line(char *line, int line_size)
{
return line_size == 0 || is_eol(line)
}
is_eol , . ..
, - :
int is_eol(char *line)
{
...
return result;
}
...
int is_blank_line(char *line, int line_size)
{
return line_size == 0 || is_eol(line)
}
...
while (getline (&line, &line_size, f) != -1) {
if (is_blank_line(line, line_size)) {
printf("blank line spotted\n");
}
...
}