zoukankan      html  css  js  c++  java
  • c语言中大小写字符转换

    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
    ", str);
        
        lower(str);
        printf("lower result: %s
    ", 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
    ", str);
        
        low(str);
        printf("low: %s
    ", str);
        
        return 0;
    }

  • 相关阅读:
    var、let、const
    面向女朋友自我介绍
    ES6——class
    一个错误引发的——对异步回调与for循环(小白错误,大神勿进)
    关于this
    关于作用域
    HTML5 8
    HTML5 7
    HTML5 6
    HTML5 4
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14818721.html
Copyright © 2011-2022 走看看