Mail Archives: djgpp/1998/08/31/03:00:33
Destination: Adam Brown <adambrown1 AT geocities DOT com>
From: Gruber Gerhard
Group: comp.os.msdos.djgpp
Date: Sun, 30 Aug 1998 17:59:29 +0200:
>> fgets() is a good deal safer than gets().
>> sscanf() does a hell of a better job than sprintf() at handling input.
>
>In what way?
sscanf() reads the input from a memory region and thus you already know the
maximum amount of memory that will be needed. This is only neccessary for
strings, though, because scanf() reads up to the next whitespace or CR. This
means you provide i.e. 30 characters for a string and the user types in 40 and
BINGO! your program crashes.
--
Bye,
Gerhard
email: sparhawk AT eunet DOT at
g DOT gruber AT sis DOT co DOT at
Spelling corrections are appreciated.
- Raw text -