当前位置:网站首页>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
边栏推荐
- [typora installation package] old typera installation package, free version
- Ceramic metal crowns - current market situation and future development trend
- 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
- Human resource management online assignment
- On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
- In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
- MySQL advanced SQL statement (1)
- High level application of SQL statements in MySQL database (I)
- Write the first CUDA program
- Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them
猜你喜欢

Pyinstaller packaging py script warning:lib not found and other related issues

Idea if a class cannot be found, it will be red

Small program graduation project based on wechat reservation small program graduation project opening report reference

TP5 automatic registration hook mechanism hook extension, with a complete case

MySQL advanced SQL statement (1)

Douban scoring applet Part-3

The automatic control system of pump station has powerful functions and diverse application scenarios

Basic editing specifications and variables of shell script

Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge

JVM performance tuning and practical basic theory - medium
随机推荐
Life cycle of instance variables, static variables and local variables
2022 electrician (elementary) examination question bank and electrician (elementary) simulation examination question bank
Small program graduation project based on wechat examination small program graduation project opening report function reference
Huawei rip and BFD linkage
Jerry's update contact [article]
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
C import Xls data method summary III (processing data in datatable)
The latest analysis of hoisting machinery command in 2022 and free examination questions of hoisting machinery command
2022 R2 mobile pressure vessel filling certificate examination and R2 mobile pressure vessel filling simulation examination questions
Experimental animal models - current market situation and future development trend
Idsia & supsi & usi | continuous control behavior learning and adaptive robot operation based on Reinforcement Learning
Conditional test, if, case conditional test statements of shell script
MySQL deadly serial question 2 -- are you familiar with MySQL index?
String & memory function (detailed explanation)
Sequence sorting of basic exercises of test questions
MySQL statement learning record
Yyds dry goods inventory override and virtual of classes in C
Small program graduation project based on wechat video broadcast small program graduation project opening report function reference
SQL statement