Briefly describe printf (& quot; % * s % s & quot;, xx); or printf (& quot; % * s \ n & quot ;, xx, xx);, printfs % s

Source: Internet
Author: User

Simply put, printf ("% * s % s", xx); or printf ("% * s \ n", xx, xx);, printfs % s

Do you still remember this example?

  1 #include "public.h"  2   3 int main()  4 {  5     int a=4;  6     printf("%4d\n",a);  7     return 0;  8 }

The output result is:

4

There are three leading Spaces

Printf ("% * s",) is similar

"*" Indicates the number of locations

The first s represents a string.

The first parameter represents the number of digits, and the second parameter represents the string. The two parameters are combined to indicate the number of digits of the string. If not, use spaces on the left to complete the number of digits. maybe I am not talking too clearly. Let's use the code below to explain it.

  1 #include <stdio.h>  2   3 int main()  4 {  5     char *s="12345";  6     char ss='a';  7     printf("%*s\n",10,s);  8     printf("%*c\n",4,ss);  9 }

### Gcc text. c
###./A. out
12345
A
###

We can see that there are five spaces in front of 12345, plus 10 spaces in total in 12345, three spaces in front of a, and four spaces in total in front of.


Printf ("% s % d \ n", printf ("\ n ");

For (I = 0; I <maxcircle; I);/* line feed after each line */because if (xx [I] [j] = 'O') R_INsock_in; m_socket = so

Printf ("% s \ n", xx [I]); scanf ("% d ",

Main () (separated by commas): "); for example, q-> red = true, q-> link [0]-> red = false, q-scanf ("% d ",

Related Article

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.