[問題] 檔案比對
我是程式初學者,想寫一個檔案內容比對的小程式
程式如下
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE *f1=fopen("1.txt","r");
FILE *f2=fopen("2.txt","r");
char a[50],b[50];
int n=50;
fgets(a,n,f1);
fgets(b,n,f2);
while(a!=EOF&&b!=EOF)
{
if(strcmp(a,b))
printf("not the same");
else
printf("the same");
}
fclose(f1);
fclose(f2);
system("PAUSE");
return 0;
}
當編譯後他說strcmp不能比較pointer或integer
試了很久還是不太懂該怎麼修正
麻煩各位大大解惑了~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.89.100
推
09/23 20:36, , 1F
09/23 20:36, 1F
→
09/23 20:38, , 2F
09/23 20:38, 2F
→
09/23 20:39, , 3F
09/23 20:39, 3F
→
09/23 21:58, , 4F
09/23 21:58, 4F
推
09/25 16:07, , 5F
09/25 16:07, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章
11
38