/**
 * Copyright (c) 2001,2002 Yoon, Hyunho <hhyoon@kldp.org>
 * http://mooo.org
 * ----------------------------------------------------------------------
 *
 * LICENSE
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
/*
 * str_tolower(), str_toupper()
 *
 * char *str_tolower(const char *str)
 *  1. 문자열을 소문자로 바꿔주는 함수 ..
 *  2. 함수의 매개변수를 문자열로 받아 그 문자열의 대문자를 소문자로 ..
 *     바꾼 문자열을 저장한 다음, 그 문자열을 반환해준다.
 *
 * char *str_toupper(const char *str)
 *  1. 문자열을 대문자로 바꿔주는 함수 ..
 *  2. 함수의 매개변수를 문자열로 받아 그 문자열의 소문자를 대문자로 ..
 *     바꾼 문자열을 저장한 다음, 그 문자열을 반환해준다.
 */
#include <stdio.h>
#define MAX        81
char *str_tolower(const char *str);
char *str_toupper(const char *str);
int main()
{    char str[MAX] = "Welcome to Bitcamp!";
    char *lower, *upper;
   // 문자열을 변환한다.
    lower = str_tolower(str);
    upper = str_toupper(str);
    printf("Origin string: %s\n", str);
    printf("Lower string: %s\n", lower);
    printf("Upper string: %s\n", upper);
    return 0;
}char *str_tolower(const char *str)
{    int i;
   // 함수라 리턴된 후에도 buffer의 내용을 사용하기 위해
   // static으로 선언한다.
    static char buffer[MAX];
    for (i = 0; str[i] != '\0'; i++) {
       // 현재 문자가 대문자인지 검사한다.
       // 대문자라면 소문자로 바꾼다.
        if (str[i] >= 'A' && str[i] <= 'Z')
            buffer[i] = str[i] + ('a' - 'A');
        else
            buffer[i] = str[i];
    }
    return buffer;
}char *str_toupper(const char *str)
{    int i;
    static char buffer[MAX];
    for (i = 0; str[i] != '\0'; i++) {
       // 현재 문자가 소문자인지 검사한다.
       // 소문자라면 대문자로 바꾼다.
        if (str[i] >= 'a' && str[i] <= 'z')
            buffer[i] = str[i] - ('a' - 'A');
        else
            buffer[i] = str[i];
    }
    return buffer;
}
이 작은숲 문서의 출처는 위키노트의 위키노트/C 언어 예제/대·소문자로 만드는 함수 문서입니다.