I'm a little newbie in C.
./main 7 4
This command in terminal causes that argv[1] = 7, argv[2] = 4.
./main <input.in
When I use redirecting of stdin in terminal, it only shows argc = 1(./main).
Is there any way how to solve this problem or do i have to try a different way?
You shell interprets the <file.txt as "send file.txt's contents to this processes' stdin", so your program will never see the <file.txt part.
There is no way to resolve this, as this is a deliberate feature of POSIX (and possibly other) shells.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With