Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!warwick!diamond!geoff From: geoff@cs.warwick.ac.uk (Geoff Rimmer) Newsgroups: comp.lang.c Subject: Re: strcpy & declaration of functions Message-ID: Date: 11 Jun 89 22:57:26 GMT References: <4400001@tdpvax> Sender: news@warwick.ac.uk Organization: Computer Science, Warwick University, UK Lines: 46 In-reply-to: scott@tdpvax.UUCP's message of 8 Jun 89 22:48:00 GMT In article <4400001@tdpvax> scott@tdpvax.UUCP writes: > extern int atoi(); or > int atoi(); I prefer the former, except I would write it: extern int atoi( const char * ); To extern or not to extern - it really doesn't matter with FUNCTION declarations. In the case of variables, "extern int foo;" and "int foo;" can be very different. But let's not get into tentative definitions! > I myself lean toward the first so that you know the function is not > in the file. Not necessarily. If ultra.c contains the function eggnog(), and violet.c calls eggnog(), it is usual to put the declaration of eggnog in a header file ultra.h, and then have ultra.c and violet.c #include ultra.h. So, even though ultra.c is seeing the "extern int eggnog();", the function eggnog() *is* in the same file. > The second question deals with strcpy(). Is it like memcpy in that if the > arguments memory overlap the behavior is undefined or is it different. Is > pre-ANSI and ANSI different on this. For ANSI C: "There are two groups of string functions defined in the header . The first have names beginning with 'str'; the second have names beginning with 'mem'. Except for 'memmove', the behavior is undefined if copying takes place within overlapping opjects." - K&R2 B3 p249. Geoff /---------------------------------------------------------------\ | GEOFF RIMMER | | email : geoff@uk.ac.warwick.cs | | address : Computer Science Dept, Warwick University, | | Coventry, England. | | PHONE : +44 203 692320 | | FAX : +44 865 726753 | \---------------------------------------------------------------/ "No representation without taxation!" - Rik Mayall, The New Statesman.