Article View: comp.os.os2.programmer
Article #3494Re: Cset/2 libraries and ANSI
From: jcburt
Date: Thu, 21 Jan 1993 17:12
Date: Thu, 21 Jan 1993 17:12
44 lines
2126 bytes
2126 bytes
In article <19930120.073423.677@almaden.ibm.com> dmm@vnet.ibm.com (Dave Mooney) writes:
>In <1993Jan20.134902.1090@ludd.luth.se> Bjorn Fahller writes:
>> Lookup sprintf in the doc's just to find that contrary
>> to anything else I've ever seen, it returns an integer telling how many
>> characters was put into the buffer, instead of the pointer to it.
>> Why is this? Or is it so that all other libraries I've seen are not
>> ANSI conformant, and that what I've always thought to be ANSI isn't?
>> What more such surprices are there?
>
>sprintf() has returned an integer ever since the earth cooled. You are
>perhaps confusing it with the strxxx() routines, which often return a
>pointer to the string they have just manipulated? In order to avoid
>surprises like this, I recommend that you always include prototypes for
>the functions you are using (by #include-ing the appropriate headers)
>and compiling with -Kb.
>
>dave
>
Dave,
Perhaps in your world sprintf() returns an integer, but on the SUN
things are a bit different...and I quote (from SUN man page)
PRINTF(3S) STANDARD I/O FUNCTIONS PRINTF(3S)
NAME
printf, fprintf, sprintf - formatted output conversion
SYNOPSIS
#include <stdio.h>
int printf(format [ , arg ] ... )
char *format;
int fprintf(stream, format [ , arg ] ... )
FILE *stream;
char *format;
char *sprintf(s, format [ , arg ] ... )
char *s, *format;
hmmm...seems like sprintf returns a character pointer just like the
original poster was saying...and people wonder why porting software
is such a *fun* task...:-)
John
Technical Details
Message-ID:
<1jmlhnINNce9@rave.larc.nasa.gov>Path:
arc1-ca.pugleaf.net!sparky!uunet!news.larc.nasa.gov!gatsibm.larc.nasa.gov!jcburtReferences:
<1993Jan20.134902.1090@ludd.luth.se> <19930120.073423.677@almaden.ibm.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!news.larc.nasa.gov!gatsibm.larc.nasa.gov!jcburt From: jcburt@gatsibm.larc.nasa.gov () Newsgroups: comp.os.os2.programmer Subject: Re: Cset/2 libraries and ANSI Date: 21 Jan 1993 17:12:23 GMT Organization: NASA Langley Research Center Lines: 46 Message-ID: <1jmlhnINNce9@rave.larc.nasa.gov> References: <1993Jan20.134902.1090@ludd.luth.se> <19930120.073423.677@almaden.ibm.com> NNTP-Posting-Host: gatsibm.larc.nasa.gov