回答編集履歴

3

追記

2019/04/23 09:47

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
 
7
7
  それは文字列の名前だけ([]が付かない)の比較じゃないでしょうか?
8
+
9
+ __※わたしも探してみましたが文字列を途中からコピーしたり比較したりする例は見つかりませんでした。__
8
10
 
9
11
 
10
12
 

2

追記

2019/04/23 09:47

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -15,3 +15,99 @@
15
15
  strcmp(newWord[i], WORDlist[i]) は、は文字をアドレスとして渡していることになります。
16
16
 
17
17
  エラーにならなければ、何が起こってもしょうがない状況です。
18
+
19
+ 「追記」
20
+
21
+ そのままコンパイルすると以下のワーニングが出ます。
22
+
23
+ ・・・説明の出来ないエラーやワーニングは潰しましょう。
24
+
25
+ 参考:[エラーメッセージの読み方と対処, 検索や質問の原則](https://qiita.com/cannorin/items/eb062aae88bfe2ad6fe5)
26
+
27
+ ```text
28
+
29
+ usr ~/Project/test % cc t4.c
30
+
31
+ t4.c:18:8: warning: implicit conversion loses integer precision: 'int' to 'char'
32
+
33
+ [-Wimplicit-int-conversion]
34
+
35
+ ch=fgetc(fp);//ファイルから一文字読み取る
36
+
37
+ ~^~~~~~~~~
38
+
39
+ t4.c:20:10: warning: implicitly declaring library function 'strcmp' with type 'int
40
+
41
+ (const char *, const char *)' [-Wimplicit-function-declaration]
42
+
43
+ if(strcmp(newWord[i], WORDlist[i]) == 0)
44
+
45
+ ^
46
+
47
+ t4.c:20:10: note: include the header <string.h> or explicitly provide a declaration for 'strcmp'
48
+
49
+ t4.c:20:17: warning: incompatible integer to pointer conversion passing 'char' to parameter of
50
+
51
+ type 'const char *'; take the address with & [-Wint-conversion]
52
+
53
+ if(strcmp(newWord[i], WORDlist[i]) == 0)
54
+
55
+ ^~~~~~~~~~
56
+
57
+ &
58
+
59
+ t4.c:20:29: warning: incompatible integer to pointer conversion passing 'char' to parameter of
60
+
61
+ type 'const char *'; take the address with & [-Wint-conversion]
62
+
63
+ if(strcmp(newWord[i], WORDlist[i]) == 0)
64
+
65
+ ^~~~~~~~~~~
66
+
67
+ &
68
+
69
+ t4.c:28:7: warning: implicitly declaring library function 'strcpy' with type
70
+
71
+ 'char *(char *, const char *)' [-Wimplicit-function-declaration]
72
+
73
+ strcpy(WORDlist[i], newWord[i]);//WORDlistに登録 文字列なので =で代入できない
74
+
75
+ ^
76
+
77
+ t4.c:28:7: note: include the header <string.h> or explicitly provide a declaration for 'strcpy'
78
+
79
+ t4.c:28:14: warning: incompatible integer to pointer conversion passing 'char' to parameter of
80
+
81
+ type 'char *'; take the address with & [-Wint-conversion]
82
+
83
+ strcpy(WORDlist[i], newWord[i]);//WORDlistに登録 文字列なので =で代入できない
84
+
85
+ ^~~~~~~~~~~
86
+
87
+ &
88
+
89
+ t4.c:28:27: warning: incompatible integer to pointer conversion passing 'char' to parameter of
90
+
91
+ type 'const char *'; take the address with & [-Wint-conversion]
92
+
93
+ strcpy(WORDlist[i], newWord[i]);//WORDlistに登録 文字列なので =で代入できない
94
+
95
+ ^~~~~~~~~~
96
+
97
+ &
98
+
99
+ t4.c:32:15: warning: variable 'ch' used in loop condition not modified in loop body
100
+
101
+ [-Wfor-loop-analysis]
102
+
103
+ for(i=0; (( ch!='\0' ) && ( ch!=EOF )); i++){ //文字列の最後に含まれている\0
104
+
105
+ ^~ ~~
106
+
107
+ 8 warnings generated.
108
+
109
+ usr ~/Project/test %
110
+
111
+
112
+
113
+ ```

1

誤記修正

2019/04/23 09:01

投稿

cateye
cateye

スコア6851

test CHANGED
@@ -14,4 +14,4 @@
14
14
 
15
15
  strcmp(newWord[i], WORDlist[i]) は、は文字をアドレスとして渡していることになります。
16
16
 
17
- ニングにならなければ、何が起こってもしょうがない状況です。
17
+ エラーにならなければ、何が起こってもしょうがない状況です。