0

在 MacOSX 上,我试图从 inp.txt 读取输入并将输出写入 Sublime 上的 outp.txt。我将标准输出重定向到 outp.txt

#include<iostream>
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("inp.txt", "r", stdin);
    // for writing output to output.txt
    freopen("outp.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    cout<<n+1;
}

错误是

ld: can't open output file for writing: /Users/sarath/Documents/code, errno=21 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Finished in 2.9s with exit code 1]
[shell_cmd: g++ "/Users/sarath/Documents/code.cpp" -o "/Users/sarath/Documents/code" && "/Users/sarath/Documents/code"]
[dir: /Users/sarath/Documents]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

为什么它失败了,请帮忙?谢谢你。

4

0 回答 0