The redirections are setting up stdin and stdout, but your program opens files named on the command line -- so it isn't using stdin and stdout.
When you run ./pa1 <test.lig &>test.out
, the <test.lig
and &>test.out
redirections are parsed as commands to the shell -- so they aren't included in your argv, which only contains {"./pa1", NULL}
.
If you want the redirections to work, then when argc
shows that no arguments have been provided, ensure that you proceed with yyin
as stdin
and yyout
as stdout
, instead of calling exit(1)
as you currently do.