Black Horse Programmer----printf function and scanf function

Source: Internet
Author: User

The printf function and the scanf function are defined in the header file stdio.h, so add # include <stdio.h> when using the scanf function. Second, the printf function 1. Definition: the printf () function is a formatted output function, generally used to output information to the terminal in the specified format; 2. Format: printf ("XXXXXXXX"); three, scanf function 1. Definition: the scanf () function enters data into the specified variable from the keyboard in a user-specified format; 2. Format: scanf ("%d", &number); The address of the &number variable 3. Attention Point

  • The SCANF function accepts only the address of the variable;
  • The scanf function is a block-type function that waits for user input;
  • Once the user has entered, the value entered by the user is assigned to the corresponding variable
  • The scanf function cannot use \ n in the first argument: scanf ("%d\n", &number);
Four, code practice 1. Practice One:

Operation Result:

2. Practice the results of the second operation:

Black Horse Programmer----printf function and scanf function

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.