[cs631apue] reading from stdin

Jan Schaumann jschauma at stevens.edu
Fri Dec 2 23:03:23 EST 2016


kthompso <kthompso at stevens.edu> wrote:
> 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)
 
> 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?

Whoops, I'm sorry.  I was thinking of another assignment, for which
fgets(3) or getline(3) would be fine.  (Hint, you'll get it on Monday.)

For the encrypt/decrypt assignment they are unsuitable for the reasons
you mentioned.

Sorry for the confusion.

-Jan


More information about the cs631apue mailing list