Transferred from: http://blog.csdn.net/anye3000/article/details/6593551Programmers with a history of C writing tend to like the printf function in particular. Even though simpler commands (such as puts) can be used, printf appears in the "hello of
In C language programming, we inevitably need to access variable parameter functions. For C languages that do not support function polymorphism, using variable parameters and macro-defined functions is a good way to implement function polymorphism.
Printf and sprintf are common and vsprintf is not.
1. Declaration of the three functions:
int printf (const char * szFormat, ...);int sprintf (char * szBuffer, const char * szFormat, ...);int vsprintf(char *string, char *format, va_list param);
2.
Instance
Write the formatted string to the variable:
Definition and usage
The vsprintf () function writes a formatted string to a variable.
Unlike sprintf (), the parameters in vsprintf () are in the array. The array elements are inserted into the
vsprintf
/* Function Name: vsprintf function: Send formatted output to string return value: Normally returns the length of the generated string (minus/0), and error conditions return negative usage: int vsprintf (char *string, Char *format,
The sprintf () format string is written to a variable.vsprintf () format the string in some of the write variables. Output: 123.000000456.000000 Grammar
sprintf(format,arg1,arg2,arg+ +)
Parameters
I. vfprintf
Function Name: vfprintf
Function: formatted data is output to the specified data stream.
Usage: int vfprintf (File * stream, char * format, va_list PARAM );
Function Description: vfprintf () will convert and format the data according to
Va_start,Function name, the process of reading a variable parameter is actually in the stack, using pointers, traversing the parameter list in the stack segment, from the low address to the high address one by one to read out the contents of the
In the Keil installation directory, where there are STDIO.H several print functions are as follows:
extern int printf (const char *, ...);
extern int sprintf (char *, const char *, ...);
extern int vprintf (const char *, char *);
extern int
Before this time, I always believe building the program with Unicode or non Unicode flag only effect the programatic side, and won't effect the system behavior. the problem arose with mixing usage of Multi-byte and Unicode Character Set
Vprintf, vfprintf, and vsprintf
Syntax:
# Include # include int vprintf (char * format, va_list arg_ptr); int vfprintf (File * stream, const char * format, va_list arg_ptr); int vsprintf (char * buffer, char * format, va_list
Study the implementation of printf. First, let's look at the function body of the printf function.Int printf (const char * fmt ,...){Int I;Char buf [256];Va_list arg = (va_list) (char *) (& fmt) + 4 );I = vsprintf (buf, fmt, arg );Write (buf, I
There are some mistakes in it, watch it.
1.va_start () va_end () function application (http://www.daydreaming.com.cn/article/2007-5-31/1838-1.htm)
1: When you cannot list the type and number of all arguments for the pass-through function , you can
In Windows, programmers who use printf in the text mode and the C language programming history in the Command column often prefer the printf function. Even though simple commands (such as puts) can be used, it is not surprising that printf appears
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
Nandflash startup and standard library issues
Put U-boot's start. S is ported to my program so that the program can be downloaded into memory with the Supervivi D feature, but not enough. Because the program is stored inside, if the power off
uart_printf () for the commonly used serial printing function, which is often used to print information through the serial port when certain conditions are met. Many developers like to use it in interrupt service programs, so only a single
It is not necessary to use variable parameters to write logs, but it is not conducive to encapsulation and the code is ugly. Today I have studied variable parameters.
First view the manual: http://www.cplusplus.com/reference/cstdio/vsprintf? KW =
Transferred from:
Http://blog.chinaunix.net/space.php? Uid = 22566367 & Do = Blog & id = 382046
Recently, I encountered an indefinite parameter problem in C language. In fact, for the problem of variable parameters in C language, only three
Abstract: printf seems to be one of the most powerful functions in the C language library, not only because it can format the output, but also because it has no limit on the number of parameters, if you need a few, you can give them a few. Printf is
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.