while(getline (&line, &line_size, f) != -1){}
I'm using this function to read line line. But i want to know when i'm reading a blank line. Can someone help?
正如 H2CO3 已经提到的,您可以使用线长度:
while (getline (&line, &line_size, f) != -1) {
if (strlen(line) == 1) {
printf("H2CO3 spotted a blank line\n");
}
/* or alternatively */
if ('\n' == line[0]) {
printf("Ed Heal also spotted the blank line\n");
}
..
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)