The use of scanf function in C language

Source: Internet
Author: User

scanf () function's control string function name: scanf function: Perform formatted input usage:intscanfChar*format[,argument,...]); The scanf () function is a universal terminal format input function that reads input information from a standard input device (keyboard). You can read any intrinsic type of data and automatically transform the values into the appropriate in-machine format. Its invocation format is: scanf ("< formatting strings >",< Address Table >The scanf () function returns the number of data items that were successfully assigned, and EOF when an error occurs. The control string is composed of three types of characters:1. format specifier;2. whitespace character;3. Non-whitespace character; (A) formatting instructions format character Description%a read in a floating-point value (only C99 valid)%A Ibid .%c read in a character%d read in decimal integer%I read in decimal, octal, hexadecimal integer%o read in octal integer%x read in hexadecimal integer%X Ibid .%c read in a character%s reads in a string%F read in a floating-point number%F Ibid .%e Ibid .%E Ibid .%g Ibid .%G Ibid .%p read in a pointer%u read into an unsigned decimal integer%n the equivalent number of characters that have been read into the value%[] Scan character Set% Read%symbol append format specifier character descriptor specifier description L/L length modifier input"Long"Data H-length modifier input"Short"Data W Integer constant Specifies the width of the input data*asterisks read one data hh,ll ibid. h,l but only valid for C99. (B) white space character whitespace character causes the scanf () function to omit one or more whitespace characters from the input in the read operation, the white space can be space,tab,newline, and so on, until the first non-whitespace character appears. (C) non-whitespace characters a non-whitespace character causes the scanf () function to reject characters that are the same as this non-whitespace character when read. 

Reference:

The use of scanf function in C language

The use of scanf 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.