Variable parameters in C Language

Source: Internet
Author: User

 

A Class of functions in c and c ++ contain a list of all uncertain parameters, such as the classic printf (char * format ,...). This article describes how to implement functions with variable-length parameters.

<Stdarg. h> contains a set of macro definitions that define how to traverse the parameter table.

There are four main types:

Va_list: Used to declare a variable. The variable references parameters in the parameter list in sequence, for example, va_list ap. The Suffix list should be a linked list.

Va_start: used to point the variables declared by the ap to the first unnamed parameter. Va_start (ap, the last famous parameter ). The Variable Length Parameter Function must contain a famous parameter.

Va_arg: return the parameter currently pointed to by the ap and ++ ap. Va_arg (ap, type)

Va_end: complete necessary cleanup.

 

From attacked Column

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.