1

I am trying to use sample.in.txt as a test input in Xcode C++. Thus, I go to edit schema and add arguments like this.

xcode command line arguments

However, when I run the project, it is still getting the input from the user and do nothing about the input file I typed on the arguments. I print the argv, then it all prints correctly.

This is my main function

    int main(int argc, char** argv) {
    
    int T;
    cin >> T;
    for(int i = 0; i < T; i++){
        int size, shift;
        cin >> size >> shift;
        Array test(size);
        for(int j = 0; j < size; j++){
            int x;
            cin >> x;
            test.add(j, x);
        }
        test.shift(shift);
    }
    return 0;
}
MikeCAT
  • 73,922
  • 11
  • 45
  • 70
yongseunglee
  • 73
  • 2
  • 8
  • Do the arguments need to be enclosed in quotes? I don't really use Xcode so I will be of limited help. – sweenish Apr 21 '21 at 12:58
  • Add quotes, but still te=he same... but thanks for your opinion! – yongseunglee Apr 21 '21 at 13:01
  • After messing around a bit, it's not worth it. The thing is, `<` is a terminal thing. You can set Xcode to use a terminal, but not once did I get it to work. It's actually locked up right now, so I don't recommend that. The arguments that you're setting are literally the arguments to the program (your `argv`) and not a shell re-direct. Being a full fledged IDE, Xcode expects you to be testing by writing test suites and not hitting run but hitting test. My recommendation would be to move away from Xcode, or at the least just use the terminal to compile and do the redirects yourself. – sweenish Apr 21 '21 at 13:40
  • Oh... Thanks for the help! Wonder why the Xcode is built this way :( – yongseunglee Apr 21 '21 at 13:55

0 Answers0