cppreference.com
en.cppreference.com › c › io › fprintf
printf, fprintf, sprintf, snprintf, printf_s, fprintf_s, sprintf_s, snprintf_s - cppreference.com
sprintf(dst, "%s and %s", dst, t); // <- broken: undefined behavior
Microsoft Learn
learn.microsoft.com › en-us › cpp › c-runtime-library › reference › sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l
sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l | Microsoft Learn
July 2, 2025 - If the buffer is too small for the formatted text, including the terminating null, then the buffer is set to an empty string by placing a null character at buffer[0], and the invalid parameter handler is invoked. Unlike _snprintf, sprintf_s guarantees that the buffer will be null-terminated unless the buffer size is zero.
TutorialsPoint
tutorialspoint.com › c_standard_library › c_function_sprintf.htm
C Library - sprintf() function
#include <stdio.h> int main() { char buffer[100]; float pi = 3.14159; sprintf(buffer, "The value of pi is %.2f.", pi); printf("%s\n", buffer); return 0; } ... The value of pi is 3.14.
Campbell Scientific
help.campbellsci.com › crbasic › cr6 › Content › Instructions › sprintf.htm
Sprintf (String Print Formatted)
PanelTemp (PTemp,15000) Battery (BattVolt) 'Generate string using SprintF '%f is used to format variables BattVolt and PTemp '%c (formatting a character code of 10) outputs a line feed Sprintf(Message, "Battery: %.2f V, Panel: %.1f °C", BattVolt, PTemp) EmailSuccess = EmailRelay (ToAddr,Subject,Message,ServerResp) NextScan EndProg
Cplusplus
cplusplus.com › reference › cstdio › sprintf
Sprintf
int sprintf ( char * str, const char * format, ... ); Write formatted data to string · Composes a string with the same text that would be printed if format was used on printf, but instead of being printed, the content is stored as a C string in the buffer pointed by str.
Programiz
programiz.com › cpp-programming › library-function › cstdio › sprintf
C++ sprintf() - C++ Standard Library
#include <cstdio> #include <iostream> using namespace std; int main() { char buffer[100]; int age = 23; // print "My age is " and age variable to buffer variable sprintf(buffer, "My age is %d", age); // print buffer variable cout << buffer; return 0; } // Output: My age is 23
Tenouk
tenouk.com › cpluscodesnippet › usingsprintf_s.html
Displaying a formatted output using C standard output sprintf()/sprintf_s() function
sprintf_s(s, 80, "Integer:m\nFloat:%8.2f", x, y); printf("\n%s\n%s\n", "The formatted output stored in array s is: ", s); return 0; } Output example: Using sprint() -------------- Enter an integer and a float, separated by space: 100 212.45 · The formatted output stored in array s is: Integer: ...
Oracle
docs.oracle.com › cd › E88353_01 › html › E37843 › sprintf-s-3c.html
sprintf_s - man pages section 3: Basic Library Functions
July 27, 2022 - The dprintf() function places output on the file associated with the file descriptor fildes rather than on a stream. The sprintf() function places output, followed by the null byte (\0), in consecutive bytes starting at s; it is the user's responsibility to ensure that enough storage is available.
Embarcadero
docwiki.embarcadero.com › RADStudio › Sydney › en › Sprintf_s,_swprintf_s
sprintf_s, swprintf_s - RAD Studio
#include <stdio.h> #include <math.h> int main(void) { char buffer[80]; sprintf_s(buffer, 40, "An approximation of Pi is %f\n", M_PI); puts(buffer); return 0; }
Rurban
rurban.github.io › safeclib › doc › safec-2.1 › d3 › d21 › sprintf__s_8c.html
safec: sprintf_s.c File Reference
If the buffer dest is too small for the formatted text, including the terminating null, then the buffer is set to an empty string by placing a null character at dest[0], and the invalid parameter handler is invoked. Unlike _snprintf, sprintf_s guarantees that the buffer will be null-terminated unless the buffer size is zero.
Cplusplus
cplusplus.com › forum › general › 140223
sprintf_s correct usage - C++ Forum
August 10, 2014 - Hey there, I'm having a bit of trouble with sprintf_s(). I keep getting a currupted format into my buffer when I use it and an Access Violation. I assume I'm using it incorrectly.
GitHub
github.com › MicrosoftDocs › cpp-docs › blob › main › docs › c-runtime-library › reference › sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md
cpp-docs/docs/c-runtime-library/reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md at main · MicrosoftDocs/cpp-docs
If the buffer is too small for the formatted text, including the terminating null, then the buffer is set to an empty string by placing a null character at buffer[0], and the invalid parameter handler is invoked. Unlike _snprintf, sprintf_s guarantees that the buffer will be null-terminated unless the buffer size is zero.
Author MicrosoftDocs
W3Schools
w3schools.com › c › ref_stdio_sprintf.php
C stdio sprintf() Function
If you write too many characters it may begin overwriting memory which belongs to other variables or other programs. A safe alternative to this function is the snprintf() function. sprintf(char * destination, const char * ...
Tenasys
support.tenasys.com › 6-2 › sprintf
sprintf, sprintf_s, swprintf, swprintf_s
#include <stdio.h> int sprintf (char *buffer, const char *format[, argument]...); int sprintf_s(char *buffer, rsize_t buflen, const char *format[, argument]...); #include <wchar.h> int swprintf(wchar_t *buffer, size_t buflen, const wchar_t *format[, argument]...); int swprintf_s(wchar_t *buffer, ...
MathWorks
mathworks.com › matlab › language fundamentals › data types › characters and strings
sprintf - Format data into string or character vector - MATLAB
Example: '%s' converts [65 66 67] to ABC. Numeric, character, or string arrays. Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string · Input text without formatting operators, specified as a character vector or string scalar. ...