C语言-常用函数处理

1.使用fgets

#define SLEN 50

char str[SLEN];

fgets(str, SLEN, stdin);

i = 0;
while (str[i] != '
' && str[i] != '')
    i++

if (str[i] == '
')
    str[i] = ''
else
    while (getchar() != '
')
        continue;

2.使用getchar()过滤掉输入缓存中的剩余部分

void eatline(void) {
    while (getchar() != '
')
        continue;
}

3.

  

原文地址:https://www.cnblogs.com/JohnABC/p/4612492.html