[cs631apue] reading from stdin
kthompso
kthompso at stevens.edu
Fri Dec 2 22:59:47 EST 2016
On 12/02/2016 10:22 PM, Jan Schaumann wrote:
> kthompso <kthompso at stevens.edu> wrote:
>> > Should we use fgets to read from stdin or will the read system be okay?
>>
>> I would not use fgets(3) to read in the data. From the documentation:
>
> I see nothing wrong with using fgets(3)
Would efficiency be a concern? Presumably fgets(3) loses some time
comparing
the input characters for newlines and EOF. Then you have to parse the
data a
second time to get the length of the input using strlen(3).
What would happen when reading in encrypted/binary data if you encounter
EOF?
Couldn't fgets(3) return NULL, despite not actually reaching the end of
the
input? How would you know when to stop reading in data?
-Kyle
More information about the cs631apue
mailing list