Resetting pointer to the start of file

后端 未结 2 2088
时光取名叫无心
时光取名叫无心 2020-12-15 18:16

How would I be able to reset a pointer to the start of a commandline input or file. For example my function is reading in a line from a file and prints it out using getchar(

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-15 18:54

    Piped / redirected input doesn't work like that. Your options are:

    • Read the input into an internal buffer (which you already seem to be doing); or
    • Pass the file name as a command-line argument instead, and do with it as you please.

提交回复
热议问题