#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string> //利用string来完成对比
using namespace std;
int main(int argc, char *argv[]) {
char path_a[111], path_b[111]; cin >> path_a >> path_b; //读入要对比文件的路径
string content_a, content_b; //保存文件内容
char cache; //缓存
freopen(path_a, "r", stdin); //打开文件a
while (scanf("%c", &cache) != EOF) content_a += cache; //保存
fclose(stdin); //关闭文件a
freopen(path_b, "r", stdin); //打开文件b
while (scanf("%c", &cache) != EOF) content_b += cache; //保存
fclose(stdin); //关闭文件b
if (content_a == content_b) cout << "SAME!" << endl;
else cout << "NOT SAME!" << endl; //输出判断结果
return 0;
};
[C++]txt文件对比
最新推荐文章于 2024-08-06 11:33:45 发布