0

When I try to use an input file in command line, for some reason the program dont indentify to file. It says in argc that it is still 1 and acts like it havnt got any file.

int main(int argc, char *argv[])
{
    printf("%d\n",argc);
    return 0;
}

Like when I try to this code it print 1, but Igave an arguments of file so it need to print 2. I put the command line arguments in Project->Properties->Debugging->Command Arguments->(file name)

edit: here's a picture of my program and setting hope it will make things clearer.

enter image description here

operout
  • 37
  • 3
  • Did you try calling on command line? How do you call your program? – Gerhardh May 31 '20 at 10:29
  • How did you use an input file in command line? Can you share the step with us? – Mr Qian Jun 01 '20 at 09:15
  • Besides, could you please share the error which program did not identify to file with us? – Mr Qian Jun 01 '20 at 09:21
  • How do you specify the input file in the command line? what is the exact command line you write. It is impossible to guess what you can have written, so it is impossible to guess what you pretend. – Luis Colorado Jun 01 '20 at 09:22
  • Hi friend, any update for this issue? Can my answer make some help for this issue? – LoLance Jun 12 '20 at 01:43

1 Answers1

0

Try using input.txt instead of <input.exe. And it would work to print 2.

About how to read the values within the input.txt file you can refer to my post here.

halfer
  • 19,824
  • 17
  • 99
  • 186
LoLance
  • 25,666
  • 1
  • 39
  • 73