|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
/* 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;
}
该贴已经同步到 空手套小白狼的微博 |
|