c语言 11-7

1、

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

void str_toupper(char *s)
{
    while(*s)
    {
        *s = toupper(*s);
        s++;
    }
}

void str_tolower(char *s)
{
    while(*s)
    {
        *s = tolower(*s);
        s++;
    }
}

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

 

posted @ 2021-06-01 21:44  小鲨鱼2018  阅读(27)  评论(0编辑  收藏  举报