Article View: comp.lang.c.moderated
Article #2653Re: ANSI-C/GCC/LCLINT snprintf() ??
From: Florian Große-Coosmann
Date: Mon, 14 Aug 2000 00:00
Date: Mon, 14 Aug 2000 00:00
24 lines
1891 bytes
1891 bytes
Efraim Mostrom wrote:
>
> Hi!
>
> Short code for exemple:
>
> #include <stdio.h>
> int main(int * argc, char * argv[]) {
> char *buf[1024];
> if ((snprintf(buf,1024,"string : %s string2 : %s",argv[1],argv[2])) == -1) {
> fprintf(stderr,"main : error while snprintf() \n");
> exit(1);
> }
> fprintf(stdout,"buf = %s\n",buf);
> return 0;
> }
Is this a typo while building this example?
You wrote "char *buf[1024]" in case of "char buf[1024]". snprintf is defined
at least in glibc 2.0 but returns correct values only in version 2.1+.
The return of the error value -1 should work in all cases.
Florian
--
comp.lang.c.moderated - moderation address: clcm@plethora.net
Technical Details
Message-ID:
<clcm-20000814-0011@plethora.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<clcm-20000811-0005@plethora.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10aedf,99e7fdc5e0986bd X-Google-Attributes: gid10aedf,public X-Google-Thread: f65d0,99e7fdc5e0986bd X-Google-Attributes: gidf65d0,public X-Google-Thread: 100850,99e7fdc5e0986bd X-Google-Attributes: gid100850,public From: Florian Große-Coosmann <florian@grosse-coosmann.de> Subject: Re: ANSI-C/GCC/LCLINT snprintf() ?? Date: 2000/08/14 Message-ID: <clcm-20000814-0011@plethora.net> X-Deja-AN: 658262227 X-Old-trace: wrath.news.nacamar.de 966246919 58460 195.52.197.66 (14 Aug 2000 09:55:19 GMT) Content-Transfer-encoding: 7bit Approved: clc@plethora.net References: <clcm-20000811-0005@plethora.net> X-Accept-language: de-DE, de, en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@plethora.net X-Trace: 966284251 gemini.plethora.net 72533 clcm@205.166.146.1 Organization: Nacamar Data Communications GmbH X-Old-complaints-to: abuse@nacamar.de Mime-Version: 1.0 X-Clcm-spamtrap-trap: http://www.alladvantage.com/ Newsgroups: comp.lang.c.moderated,gnu.gcc,linux.dev.c-programming Originator: clcm@plethora.net (Comp Lang C'Moderated)