program6_06.c
来自「C语言入门经典一书的所有代码。书上面的所有代码均在此。希望大家喜欢」· C语言 代码 · 共 25 行
C
25 行
/* Program 6.6 Comparing strings */
#include <stdio.h>
#include <string.h>
int main(void)
{
char word1[20]; /* Stores the first word */
char word2[20]; /* Stores the second word */
printf("\nType in the first word:\n 1: ");
scanf("%19s", word1); /* Read the first word */
printf("Type in the second word:\n 2: ");
scanf("%19s", word2); /* Read the second word */
/* Compare the two words */
if(strcmp(word1,word2) == 0)
printf("You have entered identical words");
else
printf("%s precedes %s",
(strcmp(word1, word2) < 0) ? word1 : word2,
(strcmp(word1, word2) < 0) ? word2 : word1);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?