www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/31/03:00:33

From: sparhawk AT eunet DOT at (Gerhard Gruber)
Newsgroups: comp.os.msdos.djgpp
Subject: Re:
Date: Mon, 31 Aug 1998 06:47:42 GMT
Organization: EUnet Austria
Lines: 27
Message-ID: <35ea9738.15981717@news.Austria.EU.net>
References: <E0zBoRN-0004QX-00 AT sable DOT ox DOT ac DOT uk> <35E881DF DOT 7106 AT geocities DOT com> <6sb36g$hos AT news-central DOT tiac DOT net> <35E976E1 DOT 3B00 AT geocities DOT com>
NNTP-Posting-Host: e167.dynamic.vienna.at.eu.net
Mime-Version: 1.0
NNTP-Posting-Date: 31 Aug 1998 06:49:24 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019