C-based input and output functions

Source: Internet
Author: User

1. Most commonly used scanf and printf, to include header files Stdio.h

1.1 Output printf

Format: printf ("< formatted string >", < parameter table >)

1.1.1 "" contains a string of 3 object types
* Unformatted characters are copied directly to the output stream that is the general character direct output
* Output by corresponding data type with a format character such as:%d-integer%s-string
* Escape character is output by escaping, e.g. \ n output carriage return, \ t output tab
1.1.2 Control Display Value width

1 intx = -;2printf"x=%1d", x);//Output x=183printf"x=%3d", x);//Output x=4printf"x=%5d", x);//Output x=5 6printf"X=%-1dt", x);//Output x=18t7printf"X=%-3dt", x);//Output x=18 T8printf"X=%-5dt", x);//Output x=18 T9                     Ten Doublex =1.5; Oneprintf"x=%ft", x);//Output x=1.500000t Aprintf"x=%10ft", x);//Output x= 1.500000T -printf"x=%10.3ft", x);//Output x= 1.500T -  theprintf"x=%-8.3ft", x);//Output x=1.500 T -printf"x=%-ft", x);//Output x=1.500000t -printf"x=%-2.2ft", x);//Output x=1.50t

1.2 Input scanf
Format: scanf ("< format description string >",< variable address >);

1.2.1

C-based input and output functions

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.