亚洲一级免费看,特黄特色大片免费观看播放器,777毛片,久久久久国产一区二区三区四区,欧美三级一区二区,国产精品一区二区久久久久,人人澡人人草

C語(yǔ)言

c語(yǔ)言strcmp的用法

時(shí)間:2025-02-18 03:08:51 C語(yǔ)言 我要投稿
  • 相關(guān)推薦

c語(yǔ)言strcmp的用法

  函數(shù) int stringcompare(char *source, char *target) 比較字符串 source 和 target,并根據(jù) source 是否小于、等于或大于 target 的結(jié)果分別返回負(fù)整數(shù)、0或者整數(shù)。該返回值是 source 和 target 由前后逐字符比較時(shí)遇到的第一個(gè)不相等字符處的字符的差值。下面小編就來(lái)為大家介紹下c語(yǔ)言strcmp的用法。

  #include

  int stringcompare(char *source, char *target);

  int main()

  {

  char str_a[] = "Welcome to www.nowamagic.net";

  char str_b[] = "Welcome to www.nowamagic.net";

  int wait, result;

  result = stringcompare(str_b, str_a);

  printf("After Function Call: ");

  printf("result is '%d' ", result);

  scanf("%d", &wait);

  }

  /* 根據(jù) source 按照字典順序小于、等于或大于 target 的結(jié)果分別返回負(fù)整數(shù)、0或者整數(shù) */

  int stringcompare(char *source, char *target)

  {

  int i;

  for(i = 0; source[i] == target[i]; i++)

  {

  if (source[i] == '