Use stdarg. h to implement simple printf (variable length parameter), stdarg. hprintf
This mainly enables stdarg. h to support variable parameters.
The key steps are as follows:
1. Define a va_list variable ap.
2. initialize the ap so that it
Today, I was bored with the computing method lesson, so I took a look at the C ++ programming path .. I accidentally saw # include va_list, va_start, va_end and other things. I don't know how to use them, so I really want to solve them ..
After
Stdarg. H is the header file of C standard function library in C language. stdarg is simplified by standard (standard) arguments (parameters) to enable the function to receive variable parameters. The cstdarg header file of C ++ also provides this
Now, we will first explain the following process:
◎ Usage:Func (type para1, type para2, type para3 ,... ){/****** Step 1 ******/Va_list AP;Va_start (AP, para3); // be sure to "…" The previous parameter, and this parameter cannot make the reference
Http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.10.html.
Author: Eric Huss
Chinese translator: Liu jinhong poechant
Copyright Disclaimer: the original text in this article is copyrighted by Eric Huss, and the Chinese translation is copyrighted by
The C function must beProgramThe following macros are used:Void va_start (va_list arg_ptr, prev_param );
Type va_arg (va_list arg_ptr, type );
Void va_end (va_list arg_ptr );
Va here is the meaning of Variable-argument (Variable
Stdarg. h defines the method for processing variable parameter functions. Some of our commonly used functions, such as printf and scanf, are used for processing. They are rarely used when writing code. However, we need to learn one more method to
Preface:This article is adapted from the article "Variable Parameter usage in C Language" by kevintz, a netizen. before writing this article, I would like to express my sincere respect and thanks to this predecessor.1. What are variable
The first time PHP compilation and installation was successful, because freetype was required to be added, so re-compilation was required, and the result could not pass configure. Centos7 information uname-aLinuxdev3.10.0-327.el7.x86_64 #1SMPThuNov19
Variable-length parameters in C language are rarely used in self-designed interfaces during development. However, printf is the most commonly used parameter interface, while feeling the strong charm of printf, do you want to figure out how 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.