Ask coding questions

← Back to all posts
How do I run a program on repl.it by specifying command line arguments? eg. a.out 3 ab a b
Qaimaq (0)

So I have these code lines:

int main(int argc, char *argv[]){

for(int i = 0; i < argc; i++){
cout << argv[i] << endl;
}

return 0;
}

What I am expecting to get is this:
a.out
3
ab
a
c

I am trying to type this command to shell: "a.out 3 ab a c", but it does not work

Comments
hotnewtop
Qaimaq (0)

I figured it out instead of just typing a.out I was needed to type ./a.out)