コンパイルエラーの原因がわからず困っています。
こんばんは。
どなたか以下のプログラム(test4.c)が何故コンパイル出来ないのか教えて頂けませんか。行数は見やすいように一時的につけさせて頂きました。
1 #include<stdio.h>
2 #include<stdlib.h>
3 #include<string.h>
4 #include<unistd.h>
5 #include<errno.h>
6 #include<signal.h>
7 #include<sys/types.h>
8
9
10
11
12
13 int main(){
14 FILE *fp,*fp2;
15 char str[1024];
16 char *tok;
17 char buf[256];
18 fp = fopen("file.txt","r");
19 int i = 0;
20 fp2 = fopen("out.txt","a");
21
22 while((str = fgets(str,1024,fp)) == EOF){
23
24 while(1){
25 // 前文を取得
26 tok = strtok(str, "(");
27 printf("%s\n",tok);
28 strcat(buf, tok);
29
30 // 中文を取得
31 tok = strtok(NULL, ")");
32 if(tok == NULL)break;
33 tok = strtok(NULL, ")");
34 if(tok == NULL)break;
35
36 *(tok + 1) = '\0';
37 tok = strtok(NULL, "CEUFRSAP.");//フラグをトークンの材料にする
38 strcat(buf,tok);
39
40 // 後文を取得
41 tok = strtok(NULL, "(");
42 tok = strtok(NULL, ")");
43 strcat(buf,"tcp ");
44 strcat(buf,tok);
45 break;
46 }
47 printf("%s\n",buf);
48 printf("%d行目です/n",i++);
49 fputs(buf,fp2);
50 }
51
52 printf("合計%d行です\n",i);
53 fclose(fp);
54 fclose(fp2);
55 return 0;
56 }
以下がコンパイルエラーの全文です。
test4.c: In function ‘main’:
test4.c:22: error: incompatible types in assignment
どんな些細な意見でも結構です。アドバイスをして頂けないでしょうか。どうぞよろしくお願いします。