Borland C++ reference

sprintf

raw OCR

Writes formatted output to a string.

Defined in header <stdio.h>

Syntax

#include <stdio.h>
int sprintf(char *buffer, const char *format[,argument,...]);

Portability

DOSUNIXWindowsANSI CC++ only
■■■■

Remarks

sprintf accepts a series of arguments, applies to each a format specifier contained in the format string pointed to by format, and outputs the formatted data to a string.

See printf for details

sprintf applies the first format specifier to the first argument, the second to

on format specifiers.

^^^ second, and so on. There must be the same number of format specifiers as arguments.

Return value

sprintf returns the number of bytes output, sprintf does not include the terminating null byte in the count. In the event of error, sprintf returns EOF.

See also

Example

#include <stdio.h>
#include <math.h>

int main(void)
{
   char buffer [80];
   sprintf(buffer, "An approximation  of pi is %f\n", M_PI);
   puts(buffer);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.