C编程,用指针将大写字符串转成小写,并输出个数。请解释谢谢。

默认分类 未结 1 1104
___青青子衿__
___青青子衿__ 2023-06-27 09:53
相关标签:
1条回答
  • 2023-06-27 10:13

    解释都在注释里,我用英文写的。#include void run (char *str){int p = 0, count = 0;while (str[p]) //not the end of the string{if (str[p] >= 'A' && str[p] <= 'Z') //if it's upper case{str[p] += 'a' - 'A'; //make it lowercount++; //increase the count}p++; //move to the next char}printf ("str = %s\n", str);printf ("count = %d\n", count);}int main(){char str[] = "asdfKIEKK";run (str);return 0;}

    0 讨论(0)
提交回复