結果

問題 No.163 cAPSlOCK
ユーザー tamane
提出日時 2019-03-27 21:14:46
言語 C
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 415 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-11 06:13:32
合計ジャッジ時間 4,393 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'conversion':
main.c:5:12: warning: comparison between pointer and integer
    5 |     if ((c >= "a") && (c <= "z")) {
      |            ^~
main.c:5:26: warning: comparison between pointer and integer
    5 |     if ((c >= "a") && (c <= "z")) {
      |                          ^~
main.c:7:19: warning: comparison between pointer and integer
    7 |     } else if ((c >= "A") && (c <= "Z")) {
      |                   ^~
main.c:7:33: warning: comparison between pointer and integer
    7 |     } else if ((c >= "A") && (c <= "Z")) {
      |                                 ^~
main.c: In function 'main':
main.c:18:24: warning: 'strlen' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
   18 |     for (int c=0; c <= strlen(S); c++) {
      |                        ^~~~~~~~~
main.c:15:10: note: source object 'S' of size 0
   15 |     char S[]={}, A[]={};
      |          ^

ソースコード

diff #

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

char conversion(char c) {
    if ((c >= "a") && (c <= "z")) {
        return (c + 0x20);
    } else if ((c >= "A") && (c <= "Z")) {
        return (c - 0x20);
    } else {
        return c;
    }
}

int main() {
    char S[]={}, A[]={};

    scanf("%s", S);
    for (int c=0; c <= strlen(S); c++) {
        A[c] = conversion(S[c]);
    }

    printf("%s", A);
    return 0;
}
0