Header File
stdio.h
Category
Memory and String Manipulation Routines
Prototype
int sprintf(char *buffer, const char *format[, argument, ...]);
int swprintf(wchar_t *buffer, const wchar_t *format[, argument, ...]);
Description
Writes formatted output to a string.
sprintf applies the first format specifier to the first argument, the second to the second, and so on. There must be the same number of format specifiers as arguments.
Return Value
On success, sprintf returns the number of bytes output. The return value does not include the terminating null byte in the count.
On error, sprintf returns EOF.
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; }
Portability
|
POSIX |
Win32 |
ANSI C |
ANSI C++ |
sprintf |
+ |
+ |
+ |
+ |
swprintf |
|
+ |
+ |
+ |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|