Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: calling argumentless function with argument Date: Sun, 06 Jan 2019 04:34:46 -0800 Organization: None to speak of Lines: 30 Message-ID: References: <7b78af94-c61a-4d48-8785-d1d6e16e3c9b@googlegroups.com> <977706ee-c6d5-4f9a-9fbc-33710a8dac39@googlegroups.com> <4bddaa2a-c31a-4d79-ab65-69b85a71ef2c@googlegroups.com> <87r2dqsdl4.fsf@bsb.me.uk> <4TlYD.88848$Sj4.69467@fx15.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="37e1c84fc256506f7000ed0114e8e372"; logging-data="12015"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gSUPnDU6W1yKKZ6qF/RcK" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:mVw27wmCf7SKznv1S16+TcK8vkM= sha1:XGqCxYwoLP5hG+F9BOtPLe8a8hw= Xref: csiph.com comp.lang.c:139461 Bart writes: > On 06/01/2019 11:58, Pascal J. Bourguignon wrote: [...] >> printf("%.*s",strlen(arg),arg); >> >> is one of the dumbest forms you can find. It should be written: >> >> printf("%s",arg); I'd use fputs(arg, stdout) but there's something to be said for the simplicity of using printf consistently. > So why did you use: > > write(0,arg,strlen(arg)); > > in your code; what's the strlen(arg) for? write() (which is defined by POSIX, not by C) doesn't work with null-terminated strings, so the strlen() is necessary. (I'm not addressing the decision to use write() rather than a standard C output function). [...] -- Keith Thompson (The_Other_Keith) kst@mib.org Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"