liujiaxin2018

c语言中大小写字符转换。

1、

#include <stdio.h>
#include <ctype.h>

void upper(char x[])
{
    int i = 0;
    while(x[i])
    {
        x[i] = toupper(x[i]);
        i++;
    }
}

void lower(char x[])
{
    int i = 0;
    while(x[i])
    {
        x[i] = tolower(x[i]);
        i++;
    }
}

int main(void)
{
    char str[128];
    printf("str: "); scanf("%s", str);
    
    upper(str);
    printf("upper result: %s\n", str);
    
    lower(str);
    printf("lower result: %s\n", str);
    
    return 0;
}

 

#include <stdio.h>
#include <ctype.h>

void upp(char x[])
{
    int i = 0;
    while(x[i])
    {
        x[i] = toupper(x[i]);
        i++;
    }
}

void low(char x[])
{
    int i = 0;
    while(x[i])
    {
        x[i] = tolower(x[i]);
        i++;
    }
}

int main(void)
{
    char str[128];
    printf("str: "); scanf("%s", str);
    
    upp(str);
    printf("upp: %s\n", str);
    
    low(str);
    printf("low: %s\n", str);
    
    return 0;
}

 

分类:

技术点:

相关文章:

  • 2022-01-13
  • 2021-07-31
  • 2021-11-26
  • 2021-09-07
  • 2021-08-29
  • 2021-11-20
猜你喜欢
  • 2021-12-18
  • 2022-03-04
  • 2022-02-03
  • 2021-12-05
  • 2022-01-20
  • 2021-10-15
  • 2022-01-04
相关资源
相似解决方案