結果

問題 No.163 cAPSlOCK
ユーザー tamane
提出日時 2019-03-28 11:28:27
言語 C
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 439 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 28,800 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 14:58:17
合計ジャッジ時間 5,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'conversion':
main.c:6:13: warning: comparison between pointer and integer
    6 |     if ((*c >= "a") && (*c <= "z")) {
      |             ^~
main.c:6:28: warning: comparison between pointer and integer
    6 |     if ((*c >= "a") && (*c <= "z")) {
      |                            ^~
main.c:7:19: warning: returning 'char *' from a function with return type 'char' makes integer from pointer without a cast [-Wint-conversion]
    7 |         return (c + 0x20);
      |                ~~~^~~~~~~
main.c:8:20: warning: comparison between pointer and integer
    8 |     } else if ((*c >= "A") && (*c <= "Z")) {
      |                    ^~
main.c:8:35: warning: comparison between pointer and integer
    8 |     } else if ((*c >= "A") && (*c <= "Z")) {
      |                                   ^~
main.c:9:19: warning: returning 'char *' from a function with return type 'char' makes integer from pointer without a cast [-Wint-conversion]
    9 |         return (c - 0x20);
      |                ~~~^~~~~~~
main.c:11:16: warning: returning 'char *' from a function with return type 'char' makes integer from pointer without a cast [-Wint-conversion]
   11 |         return (c);
      |                ^
main.c: In function 'main':
main.c:20:28: warning: passing argument 1 of 'conversion' makes pointer from integer without a cast [-Wint-conversion]
   20 |         A[c] = conversion(S[c]);
      |                           ~^~~
      |                            |
      |                            char
main.c:4:23: note: expected 'char *' but argument is of type 'char'
    4 | char conversion(char *i) {
      |                 ~~~~~~^
main.c:19:24: warning: 'strlen' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
   19 |     for (int c=0; c <= strlen(S); c++) {
      |                        ^~~~~~~~~
main.c:16:10: note: source object 'S' of size 0
   16 |     char S[]={}, A[]={};
      |          ^

ソースコード

diff #

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

char conversion(char *i) {
    char *c = i;
    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