gpt4 book ai didi

c getline 跳过空行

转载 作者:行者123 更新时间:2023-12-04 05:24:40 26 4
gpt4 key购买 nike

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");
}

..
}

关于c getline 跳过空行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13326464/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com