运行是在文件名前面加 ./,比如说编译出来是 a 就是 ./a,输入输出重定向没区别,比较是 diff 不是 fc
by mashduihca @ 2024-02-27 08:14:38
首先,没有扩展名就别写,为啥要加个 `exe` 上去?
其次,Linux 下运行当前目录文件必须写成加 `./program` 的形式,不可以省略前缀 `./`。
by kyEEcccccc @ 2024-02-27 08:14:44
@[expnoi](/user/378346)
1. linux 下可执行文件没有扩展名
2. 把 `test1.exe` 和 `test2.exe` 改为 `./test1` 和 `./test2`,把 `fc` 改为 `diff`,`system("pause")` 可以删了,或者改成 `getchar()`
by 5k_sync_closer @ 2024-02-27 08:16:55
@[mashduihca](/user/494183) @[kyEEcccccc](/user/312811) @[5k_sync_closer](/user/388651)
```cpp
#include <stdio.h>
#include <stdlib.h>
int main() {
// For Windows
// 对拍时不开文件输入输出
// 当然,这段程序也可以改写成批处理的形式
while (true) {
system("./gen > test.in"); // 数据生成器将生成数据写入输入文件
system("./test1 < test.in > a.out"); // 获取程序1输出
system("./test2 < test.in > b.out"); // 获取程序2输出
if (system("diff a.out b.out")) {
// 该行语句比对输入输出
// fc返回0时表示输出一致,否则表示有不同处
ch=getchar(); // 方便查看不同处
return 0;
// 该输入数据已经存放在test.in文件中,可以直接利用进行调试
}
}
}
```
改成这样吗
by expnoi @ 2024-02-27 14:01:33
还有那个Geany咋调缩进那些东西啊
by expnoi @ 2024-02-27 14:02:00