我是个新手写一段字符串大小写转换的代码,如下图,求告知后半段没有实现的原因是什么?
第2个while前插一行: i = 0; 忘了把 i 回到第一个字符
还有test(arr) 没写函数,注释掉。
#include <stdio.h>
#include <ctype.h>
int main()
{
char arr[] = "I Am A Student";
int i = 0;
while (arr[i])
{
if (isupper(arr[i]))
{
arr[i] = tolower(arr[i]);
}
i++;
}
printf("%s\n", arr);
i = 0;
while (arr[i])
{
if (islower(arr[i]))
{
arr[i] = toupper(arr[i]);
}
i++;
}
printf("%s\n", arr);
//test(arr);
return 0;
}