Use of scanf (Xcode development environment)

Source: Internet
Author: User

scanf Use details

    • Enter a data

int num1;

scanf ("%i", &num1);

    • Enter multiple data

int num1,num2;

printf ("Please enter 2 numbers:");

scanf ("%i%i", &num1,&num2);

Description

A input data type (%i%i) If there is no spacer, the default is to use table, carriage return, space to do the spacer

B can be clearly between%i%i with what symbol to make the spacer, such as%i,%i is to do with a comma input spacer, at this time in the use of table, carriage return, space is not working.

    • Pay special attention to the input char type data

int num1,num2;

char c;

printf ("Please enter 1 digits, 1 letters, 1 digits:");

scanf ("%i%c%i", &num1,&c,&num2);

At this point, if the table, carriage return, space to do the spacer, the data output is wrong. You can now direct the number + character + number (for example: 2#3), without any spacer, or use the specified spacer (2,#,3 at this time the comma is the spacer).

Use of scanf (Xcode development environment)

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.