sa3109.c

来自「141个C语言经典小程序」· C语言 代码 · 共 30 行

C
30
字号
#include "stdio.h"
#include "ctype.h"      /* 必需用此头文件 */

void mix_up_the_chars(char line[]);

main()
{
   char line[80];

   printf("    str=");
   scanf("%s",line);
   mix_up_the_chars(line);
   printf("new str=%s\n",line);
}

void mix_up_the_chars(char line[])
{
   int index;

   for (index = 0;line[index] != 0;index++)
   {
     if (isupper(line[index]))     /* 检查是否为大写字母*/
       line[index] = tolower(line[index]);
     else
     {
       if (islower(line[index]))  /* 检查是否为小字母 */
         line[index] = toupper(line[index]);
     }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?