How to use redirection in C for file input

前端 未结 2 727
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 14:42

I need to get the file from the terminal, I know the command will look like:

./a.out < fileName.txt

I\'m not sure how to use fgets() in

2条回答
  •  长情又很酷
    2020-12-03 15:27

    1.) you close stdin then assign a different file handler to it 2.) replace stdin with any other file handler using dup2 function you can achieve it

提交回复
热议问题