Explanation of sprintf usage in C Language 21:48:37
Tags: original sprintf files in C language, which can be reproduced. During reprinting, you must mark the original source, author information, and statement in the form of a hyperlink. Otherwise,
Int sprintf (char * buffer, const char * Format [,Argument]...);
In addition to the fixed types of the first two parameters, you can take over multiple parameters later. Its essence is obviously on the second parameter: Format String.Both printf
Original address:
http://blog.csdn.net/liukun321/article/details/5633249
SPRINTF series functions and variable parameter functions collectionThe sprintf function is defined as follows:
int sprintf (char * szbuffer, const char * szformat, ...);The
#define PRGFILENAMEFORMATEX "O%04ld.txt"sprintf (Temp,prgfilenameformatex, (Long) (Data1->pcode))int sprintf (char *buffer, const char *format [, argument] ...);In addition to the first two parameter types are fixed, can be followed by any number of
Turn from: http://blog.csdn.net/willy3000/article/details/5786888
The parameter type of the character; output formd,i int type; Displays a signed decimal number (I and D are different when used in the scanf function).o int type; unsigned octal
int sprintf (char *buffer, const char *format [, argument] ...);In addition to the first two parameter types are fixed, can be followed by any number of parameters. and the essence of it, apparently on the second parameter: Formatting the string.
The following is a detailed analysis of the use and distinction of printf (), sprintf (), scanf (), sscanf () in the C language, and the need for friends can refer to the following
PrintfSyntax:#include int printf (const char *format, ...);The
The following is a detailed analysis of the usage and differences of printf (), sprintf (), scanf (), and sscanf () in C language. For more information, see
PrintfSyntax:# Include Int printf (const char * format ,...);The printf () function prints
PrintfGrammar:#include int printf (const char *format, ...);The printf () function prints output to stdout (standard output) and other parameters according to the format given in format. The return value is the number of characters that are
Code:
Reason: When I use sprintf to pay an unsigned char value in the form of % 02x to an array or pointer of the char [2] type, the system can calculate it normally, but an error is returned: stack around the variable was too upted. Check the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.