比较两文本程序

功能:比较input1.txt和input2.txt两个文本,有不同的部分则输出0

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const int N=100;
 4 int main()
 5 {
 6     FILE *f1,*f2;
 7     char sa[N],sb[N];
 8     if ((f1=fopen("C:\\Users\\hemeiwolong\\Desktop\\input1.txt","r"))==NULL)
 9     {
10         printf("f1 open error\n");
11         exit(0);
12     }
13     if ((f2=fopen("C:\\Users\\hemeiwolong\\Desktop\\input2.txt","r"))==NULL)
14     {
15         printf("f2 open error\n");
16         exit(0);
17     }
18     while (!feof(f1))
19     {
20         fscanf(f1,"%s",sa);
21         fscanf(f2,"%s",sb);
22         printf("%s %s\n",sa,sb);
23         if (strcmp(sa,sb)==0)
24         {
25             printf("1\n");
26         }
27         else
28         {
29             printf("0\n");
30             break;
31         }
32     }
33 
34     return 0;
35 }

 

转载于:https://www.cnblogs.com/hemeiwolong/p/10432274.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值