C Language Learning notes-3. Sequential structure programming

Source: Internet
Author: User

I. Input and output of data

  Functions included in the 1.stdio.h:

GetChar (input character) gets (input string) printf (format output) Putchar (output character)

Puts (output string) scanf (format input) Flushall (flush buffer), etc.

2.flushall (); Examples of functions:

scanf ("%c", &a);

Flushall (); Action: Remove "\ n" from the buffer to prevent it from being entered

scanf ("%c", &b);

3. Format characters

Octal %o:55% #o: 055%d:45
Hexadecimal %x:2d%x:2d% #X: 0X2D%d:45
Index

%e:1.5e+11%e:1.5e+11

Other format characters:%g,%g: Automatically select%e or%f based on size

Percent: output%

%.6D: Output 6 bits, less than 0 (if more than 6 bits are output as-is)

%.6S/.6C: Output 6 bits, padded with spaces

%.6F: Set the precision to 6 digits after the decimal point (rounded)

4.SCANF ("Format control string", address list);

If, in the format control string, there are other characters besides the format description, you must enter the same character at the appropriate location when entering

5.C language whitespace characters: ', ' \ t ', ' \ n '

If the format character is like "%d%f%d", then any number of whitespace characters can be inserted between each input data at the actual input.

If "%c" is used, each character is treated as valid data (including white space characters)

If a white space character appears in the format control string, the input white space character is read in without saving until the next item is encountered

C Language Learning notes-3. Sequential structure programming

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.