scanf (), printf () function in C language

Source: Internet
Author: User
Tags function prototype

The function call scanf ("%d", &weight) contains two parameters: "%d" and &weight. c Use commas to separate multiple parameters in a function call;

However, the printf () and scanf () functions are special and the number of functions is not controlled.

For example, we can call the printf () function with 1, 2, 3, or even 4 parameters. The program needs to know the number of parameters in order to work properly, and the two functions determine the number of subsequent arguments by the first argument, by using each specifier in the first argument string corresponding to one of the following parameters.

The following statement contains two format specifiers:%d and%d

printf ("%d cats aate%d cans of tuna \ n", cats, cans);

Two format specifiers tell the program that there are two parameters; there are 2: cats and cans;

You must ensure that the number of format specifiers is the same as the number of arguments that follow. Now C checks whether the function call uses the correct number and type of parameters through a function prototype mechanism;

However, this does not work for the printf () and scanf () functions because their number of parameters is variable;

int scanf (const char *format, ...); The scanf () function declaration in man;

    

scanf (), printf () function in C language

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.