C语言输入换行符

C语言输入换行符

文章目录

gets()函数fgets() 函数

gets()函数

#include

#include

#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

#include

#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;

}

关键点

文章目录 gets()函数fgets() 函数 gets()函数 #include #include #define LEN 10 int main() { char str[10]; int result; //fgets(str, LEN, stdin); gets(str); result = strcmp(str, "\n")

相关文章