C程序的命令行执行

发布于 12-17 04:44 字数 139 浏览 2 评论 0原文

我使用 Visual Studio 2008 编写了一个 C 程序。该程序以二进制模式与文件进行比较,并告诉我们文件是否相同或不同。

我需要在命令行上执行这个程序,并且需要传递 2 个参数。 第一个参数是要比较的文件,第二个参数是要与之比较的文件。

I have a written a C program using Visual Studio 2008. The program compares to files in binary mode and tells us if the files are same or different.

I need to execute this program on command line and need to pass 2 arguments along with it.
the first argument is for the file to be compared and 2nd is the file to which it will be compared.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南笙2024-12-24 04:44:03
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv){
    int result_code;
    char command_line[256];
    sprintf(command_line, "FC /B %s %s > NUL:", argv[1], argv[2]);
    result_code=system(command_line);
    printf("%s file.\n", result_code ? "different" : "same");
    return 0;
}
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv){
    int result_code;
    char command_line[256];
    sprintf(command_line, "FC /B %s %s > NUL:", argv[1], argv[2]);
    result_code=system(command_line);
    printf("%s file.\n", result_code ? "different" : "same");
    return 0;
}
风向决定发型2024-12-24 04:44:03

看到这个。

http://www.cprogramming.com/tutorial/print/lesson14.html

你可以从谷歌获得更多信息。

See this.

http://www.cprogramming.com/tutorial/print/lesson14.html

you can get plenty more from google.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文