演習 11-7

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

void str_toupper(char *s){

    int i;

    for(i = 0; i < strlen(s); i++){
        *(s + i) = toupper(*(s + i));
    }
}

void str_tolower(char *s){

    int i;

    for(i = 0; i < strlen(s); i++){
        *(s + i) = tolower(*(s + i));
    }
}

int main(){

    char str[256];

    printf("文字列を入力してください:");
    scanf("%s", str);

    str_toupper(str);
    printf("大文字:%s\n", str);

    str_tolower(str);
    printf("小文字:%s\n", str);

    return 0;
}

0 件のコメント:

コメントを投稿