touplow.c

来自「详细介绍了一篇关于pci开发的接口芯片」· C语言 代码 · 共 30 行

C
30
字号
/*  CXL - Copyright (c) 1987-1989 by Mike Smedley - All Rights Reserved  */
/*  TOUPLOW.C   - converts a character to upper or lower case depending
                  on the previous character in the string               */

#include <ctype.h>
#include <string.h>
#include "cxlstr.h"

int touplow(char *str,char *pos,int ch)
{
    register int i;

    switch(*(pos-1)) {                  /* check previous character */
        case ' ':                       /* see if it is a separator */
        case '-':
        case '_':
        case ',':
        case '.':
        case '/':
            i=toupper(ch);              /* if it is, convert to upper */
            break;
        default:
            if(pos==str)                /* see if at beginning of string */
                i=toupper(ch);          /* if so, convert to upper */
            else
                i=tolower(ch);          /* otherwise, convert to lower */
    }
    return(i);                          /* return converted character */
}

⌨️ 快捷键说明

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