Path: utzoo!attcan!uunet!mcvax!ukc!eagle.ukc.ac.uk!icdoc!tgould!awm From: awm@gould.doc.ic.ac.uk (Aled Morris) Newsgroups: comp.lang.c Subject: Re: retiring gets(3) Message-ID: Date: 13 Nov 88 20:32:37 GMT References: <54845@<1988Nov8> <225800090@uxe.cso.uiuc.edu> Sender: news@doc.ic.ac.uk Organization: Dept. of Computing, Imperial College, London Lines: 29 In-reply-to: mcdonald@uxe.cso.uiuc.edu's message of 11 Nov 88 20:34:00 GMT I was going to suggest the following as a replacement for "gets": #define gets(buf) fgets(buf, sizeof(buf), stdin) since all the examples I've seen of "gets" in use have been: char buf[10]; ... gets(buf); But of course it won't work, (a) gets drops the newline at the end, fgets keeps it, and (b) maybe someone, has written: char *buf; buf = malloc(10); gets(buf); (although the #define would be fine in this case, it would read only 4 characters :-) I guess there isn't an easy answer :-( (but you didn't need me to tell you that) Aled Morris systems programmer mail: awm@doc.ic.ac.uk | Department of Computing uucp: ..!ukc!icdoc!awm | Imperial College talk: 01-589-5111x5085 | 180 Queens Gate, London SW7 2BZ