鱼C论坛

 找回密码
 立即注册
查看: 2222|回复: 0

字符串比较问题

[复制链接]
发表于 2012-1-18 01:26:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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




                               
登录/注册后可看大图
该贴已经同步到 空手套小白狼的微博
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-10 20:35

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表