当前位置:网站首页>Format character%* s
Format character%* s
2022-07-04 01:59:00 【666QAQ】
Knowledge point
Width and precision format parameters
- It can be omitted
- Or embedded in the format string ( Such as
%8s
,%9.2f
). - Or in the format string by
*
instructions , At this time, it is passed as another function parameter .
for example ,printf("%*d", 5, 10)
Will print 10, The total width is 5 Characters .
and printf("%.*s", 3, "abcdef")
Will print abc.
%*s
#include <stdio.h>
int main(void)
{
char buf[]="ABCDEFG123456789";
printf("%*s", 10, buf);
return 0;
}
Running results
ABCDEFG123456789
here ,*s Express s Is a variable length , Its length must be indicated by the first parameter after it , The second parameter indicates its content .
- Indicates that the print length is variable
- The next first parameter indicates its length
- The second parameter indicates its content
%.*s
#include <stdio.h>
int main(void)
{
char buf[]="ABCDEFG123456789";
printf("%.*s", 10, buf);
return 0;
}
Running results
ABCDEFG123
therefore ,
*
Specified by parameters .%*s
At least*
Characters , Fill in the blanks .%.*s
Most expressed*
Characters , Too much .
Empathy ,%*.*f
边栏推荐
- Software product download collection
- The difference between lambda expressions and anonymous inner classes
- Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
- Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
- What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
- Example 072 calculation of salary it is known that the base salary of an employee of a company is 500 yuan. The amount of software sold by the employee and the Commission method are as follows: Sales
- Force buckle day32
- Jerry's watch information type table [chapter]
- Openbionics exoskeleton project introduction | bciduino community finishing
- Containerization technology stack
猜你喜欢
MySQL deadly serial question 2 -- are you familiar with MySQL index?
Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
Introduction to superresolution
MySQL advanced SQL statement (1)
Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
Some other configurations on Huawei's spanning tree
Magical usage of edge browser (highly recommended by program ape and student party)
随机推荐
Lightweight Pyramid Networks for Image Deraining
C import Xls data method summary III (processing data in datatable)
Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
Remember another interview trip to Ali, which ends on three sides
Maximum likelihood method, likelihood function and log likelihood function
Properties of binary trees (numerical aspects)
MySQL deadly serial question 2 -- are you familiar with MySQL index?
Solution of cursor thickening
Trading software programming
2020-12-02 SSM advanced integration Shang Silicon Valley
TP5 automatic registration hook mechanism hook extension, with a complete case
Douban scoring applet Part-3
2022 R2 mobile pressure vessel filling certificate examination and R2 mobile pressure vessel filling simulation examination questions
Special copy UML notes
Three layer switching ②
JVM performance tuning and practical basic theory - medium
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
Pesticide synergist - current market situation and future development trend
Introduction to superresolution
C import Xls data method summary II (save the uploaded file to the DataTable instance object)