結果
| 問題 |
No.9006 マルチバイト文字テスト(テスト用)
|
| ユーザー |
T.Myze
|
| 提出日時 | 2015-04-13 00:17:37 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 479 bytes |
| コンパイル時間 | 653 ms |
| コンパイル使用メモリ | 20,992 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 14:05:39 |
| 合計ジャッジ時間 | 931 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:11:9: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
11 | gets(str);
| ^~~~
| fgets
main.c: In function ‘invert_str’:
main.c:26:22: warning: implicit declaration of function ‘calloc’ [-Wimplicit-function-declaration]
26 | ans = (char*)calloc(n + 1, sizeof(char));
| ^~~~~~
main.c:3:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’
2 | #include <string.h>
+++ |+#include <stdlib.h>
3 |
main.c:26:22: warning: incompatible implicit declaration of built-in function ‘calloc’ [-Wbuiltin-declaration-mismatch]
26 | ans = (char*)calloc(n + 1, sizeof(char));
| ^~~~~~
main.c:26:22: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’
main.c:34:9: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
34 | free(ans);
| ^~~~
main.c:34:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
main.c:34:9: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
main.c:34:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
/usr/bin/ld: /tmp/ccr55co3.o: in function `main':
main.c:(.text.startup+0x39): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#include <stdio.h>
#include <string.h>
void invert_str(char *str,int n);
int main(void){
char str[1000];
int n = 0;
printf("Input string->");
gets(str);
n = strlen(str);
invert_str(str, n);
return 0;
}
void invert_str(char *str,int n){
char *ans;
int i,j;
ans = (char*)calloc(n + 1, sizeof(char));
ans[n] = '\0';
for (i = n - 1, j = 0; i > -1; i--,j++){
ans[i] = str[j];
//printf("%c", str[i]);
}
printf("Inverted string->%s\n", ans);
free(ans);
}
T.Myze