Author: Robert Hyatt
Date: 16:59:40 08/29/04
Go up one level in this thread
On August 29, 2004 at 17:44:16, Alessandro Scotti wrote: >On August 29, 2004 at 12:04:47, Uri Blass wrote: > >>2)Is it safe to use fgets()? >>I remember that it is not safe to use gets() and I think that for the same >>reason it is not safe to use fgets() > >fgets() is safe. The difference with gets() is that the latter doesn't take the >buffer size as a parameter, so it can overflow your buffer. Other minor >difference s are that gets() removes end of line characters from the string, >while fgets() leaves them there, and also that gets() can only read from stdin. It isn't safe from the point of view of being able to ask "has anything been typed on the keyboard" because fgets() uses library buffering which hides input from the operating system's "is there input" query.
This page took 0.01 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.