2.1.2.44 sprintf


Description

Write data values stored in a series of user specified variables into a string according to a standard C format specification.

Syntax

int sprintf( LPSTR lpszBuffer, LPCSTR lpcszFormat, ... )

Parameters

lpszBuffer
[modify] String where formated data is written
lpcszFormat
[input]Standard C format specification
...
[input] A comma separated list of variables contains data to write to lpszBuffer

Return

Returns the number of characters which are written into the string.

Examples

EX1

void sprintf_ex1()
{
    char str1[] = "Hello", str2[50];
    char cChar = 'C';
    int N, iInt = 15;
    float fFloat = 17.56;
    N = sprintf( str2, "%s %c %d %f", str1, cChar, iInt, fFloat);
    out_str(str1);
    printf("%c\n",cChar);
    out_int("",iInt);
    out_double("",fFloat);
    printf("the string read into str2 is :\n");
    out_str(str2);
}

Remark

Write data values stored in a series of user specified variables into a string according

to a standard C format specification.

See Also

Header to Include

origin.h

Reference