当前位置:网站首页>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 .%*sAt least*Characters , Fill in the blanks .%.*sMost expressed*Characters , Too much .
Empathy ,%*.*f
边栏推荐
- When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
- Conditional test, if, case conditional test statements of shell script
- MySQL advanced SQL statement (1)
- LeetCode226. Flip binary tree
- 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
- Introduction to Tianchi news recommendation: 4 Characteristic Engineering
- Is Shengang securities company as safe as other securities companies
- Meta metauniverse female safety problems occur frequently. How to solve the related problems in the metauniverse?
- Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
- I don't know why it can't run in the project and how to change it
猜你喜欢

What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended

SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution

Override and virtual of classes in C #

The boss said: whoever wants to use double to define the amount of goods, just pack up and go

51 MCU external interrupt

C import Xls data method summary II (save the uploaded file to the DataTable instance object)

How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #

Three layer switching ①
![When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]](/img/fb/7d4a026260f8817460cc67f06e49ae.jpg)
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]

LeetCode 168. Detailed explanation of Excel list name
随机推荐
[turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration
C import Xls data method summary III (processing data in datatable)
Day05 branch and loop (II)
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
Openbionics exoskeleton project introduction | bciduino community finishing
Install the pit that the electron has stepped on
ThinkPHP uses redis to update database tables
Properties of binary trees (numerical aspects)
MySQL advanced (Advanced) SQL statement (I)
JVM performance tuning and practical basic theory - medium
Is Shengang securities company as safe as other securities companies
Huawei BFD and NQA
Do you know the eight signs of a team becoming agile?
Hbuilder link Xiaoyao simulator
PMP daily three questions (February 14, 2022)
I don't know why it can't run in the project and how to change it
Douban scoring applet Part-3
Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
MySQL deadly serial question 2 -- are you familiar with MySQL index?
Trading software programming