用c ++进行文件比较 [英] File comparison in c++

查看:86
本文介绍了用c ++进行文件比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我每次构建程序时都必须对生成的文件进行二进制比较。


例如我的第一个构建我生成一个头文件和数据文件,并将它们存储在引用目录中。下次当我再次构建程序时,我将生成相同的文件,如果它们相同,我必须比较参考目录中的文件。我见过不同的实用程序在命令行上执行文件比较。但是我必须在我的程序中包含这个比较并生成一个文件,如果文件中有任何差异。


有谁可以帮我这个?

PS:我正在研究Visual 2005,它是控制台应用程序。


谢谢。

Hi all,

I have to perform binary comparison of the generated files each time I build my program.

For example in my first build I generate a header file and data file and store them in reference directory. Next time when I build the program again I will be generating the same files and I have to compare the ones in my reference directory if they are same. I have seen different utility programs that performs file comparison on the command line. But I have to include this comparison in my program and generate a file if there are any differences in the files.

Could anyone please help me with this?

P.S: I am working on Visual 2005 and it is console application.

Thanks.

推荐答案


大家好,


我每次构建程序时都必须对生成的文件进行二进制比较。


例如,在我的第一个构建中,我生成一个头文件和数据文件,并将它们存储在引用目录中。下次当我再次构建程序时,我将生成相同的文件,如果它们相同,我必须比较参考目录中的文件。我见过不同的实用程序在命令行上执行文件比较。但是我必须在我的程序中包含这个比较并生成一个文件,如果文件中有任何差异。


有谁可以帮我这个?

PS:我正在研究Visual 2005,它是控制台应用程序。


谢谢。
Hi all,

I have to perform binary comparison of the generated files each time I build my program.

For example in my first build I generate a header file and data file and store them in reference directory. Next time when I build the program again I will be generating the same files and I have to compare the ones in my reference directory if they are same. I have seen different utility programs that performs file comparison on the command line. But I have to include this comparison in my program and generate a file if there are any differences in the files.

Could anyone please help me with this?

P.S: I am working on Visual 2005 and it is console application.

Thanks.



您的程序如何构建文件?


是逐行还是char的char?


Savage

And how is ur programm building files?

Is it line by line or char by char?

Savage


我的程序为例如,通过系统命令的头文件,它就像带有字符和数字的文本文件。另一方面,创建一个包含ASCII字符的数据文件。每次我构建我的程序时,我运行这些系统命令,并创建新版本的文件。

我想回答你的问题,我的程序是逐行构建的。

我不太明白这个问题。


如果您需要更多信息,请告诉我。


谢谢。
My program generates for example the header file through a system commandand it is like text file with characters and numbers.On the other hand a data file is created containing ASCII characters.Each time I build my program I run these system commands and new version of files are created.
I guess answer to your question, my program is building line by line.
I did not exactly understand the question.

Please let me know if you need more information.

Thanks.



我的计划例如,通过系统命令生成头文件,它就像带有字符和数字的文本文件。另一方面,创建一个包含ASCII字符的数据文件。每次构建我的程序时,我运行这些系统命令,新版本的文件是创建。

我想回答你的问题,我的程序是逐行构建的。

我不太明白这个问题。


如果你需要请告诉我更多信息。


谢谢。
My program generates for example the header file through a system commandand it is like text file with characters and numbers.On the other hand a data file is created containing ASCII characters.Each time I build my program I run these system commands and new version of files are created.
I guess answer to your question, my program is building line by line.
I did not exactly understand the question.

Please let me know if you need more information.

Thanks.



好​​的,它是逐行的,这意味着你可以创建一个简单的while循环,它将循环直到达到eof并且文件没有更新.In循环你必须测试那些线是否公平,如果新行与文件中的行不同,请将其替换为你的文件。


Savage

Ok so it''s line by line which means that u can create a simple while loop which will loop until eof is reached and files are not updated.In loop body u must test those lines for equlaity and if new line is different from line in file replace it in ur file.

Savage


这篇关于用c ++进行文件比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆