C语言输入换行符
文章目录gets()函数fgets() 函数gets()函数#include <stdio.h>#include <stdlib.h>#define LEN 10int main(){char str[10];int result;//fgets(str, LEN, stdin);gets(str);result = strcmp(str,...
·
文章目录
gets()函数
#include <stdio.h>
#include <stdlib.h>
#define LEN 10
int main()
{
char str[10];
int result;
//fgets(str, LEN, stdin);
gets(str);
result = strcmp(str, "\n") == 0 ? 1 : 0;
printf("result = %d \n", result);
system("pause");
return 0;
}

fgets() 函数
#include <stdio.h>
#include <stdlib.h>
#define LEN 10
int main()
{
char str[10];
int result;
fgets(str, LEN, stdin);
result = strcmp(str, "\n") == 0 ? 1 : 0;
printf("result = %d \n", result);
system("pause");
return 0;
}

更多推荐



所有评论(0)