結果

問題 No.729 文字swap
ユーザー card_board01card_board01
提出日時 2018-09-24 17:23:41
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 418 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 26,880 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 11:59:52
合計ジャッジ時間 2,826 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'swap':
main.c:6:12: warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
    6 |     strcpy(tmp, *a);
      |            ^~~
      |            |
      |            char
In file included from main.c:2:
/usr/include/string.h:141:39: note: expected 'char * restrict' but argument is of type 'char'
  141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
      |                      ~~~~~~~~~~~~~~~~~^~~~~~
main.c:6:17: warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
    6 |     strcpy(tmp, *a);
      |                 ^~
      |                 |
      |                 char
/usr/include/string.h:141:70: note: expected 'const char * restrict' but argument is of type 'char'
  141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
main.c:7:12: warning: passing argument 1 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
    7 |     strcpy(*a, *b);
      |            ^~
      |            |
      |            char
/usr/include/string.h:141:39: note: expected 'char * restrict' but argument is of type 'char'
  141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
      |                      ~~~~~~~~~~~~~~~~~^~~~~~
main.c:7:16: warning: passing argument 2 of 'strcpy' makes pointer from integer without a cast [-Wint-conversion]
    7 |     strcpy(*a, *b);
      |                ^~
      |                |
      |                char
/usr/include/string.h:141:70: note: expected 'const char * restrict' but argument is of type 'char'
  141 | extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
main.c:8:12: warning: passing argument 1 of 'strcpy' makes pointer from intege

ソースコード

diff #

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

void swap(char *a, char *b) {
    char tmp;
    strcpy(tmp, *a);
    strcpy(*a, *b);
    strcpy(*b, tmp);
}


int main(void) {
    
    int i, a, b;
    char str[10];
    int length;
    
    length = sizeof(str) / sizeof(str[0]);
    
    scanf("%s", str);
    scanf("%d", &a);  scanf("%d", &b);
    
    swap(&str[a], &str[b]);
    
    printf("%s", str);
    
    return 0;
}
0