当前位置:网站首页>About%*s and%* s
About%*s and%* s
2022-06-25 15:02:00 【52Hertz. six hundred and fifty】
%*s Usage of
%*s stay scanf In and in printf Different uses in .
1. stay scanf When used in , Added * The part of will be ignored , Will not be obtained by parameters .
for example :
int a,b;
char b[10];
scanf("%d%*s",&a,b);
// Input is :123 abc
that 123 The variable... Will be read a in , But the back abc Discard after reading , No variables are given ( For example, the character array here b)
2. stay printf When used in , Represents the position replaced by the following formal parameters , Realize dynamic format output .
for example :
printf("%*s", 10, s);
// It means output string s, But at least 10 A place , Insufficient in string s Fill in the space on the left , This is equivalent to printf("%10s", s);
%.*s Usage of
* Used to specify the width , Corresponds to an integer .
.( spot ) Together with the following numbers Is to specify that this width must be output , If the length of the output string is greater than this number , Output by this width , If it is less than , Then the actual length is output
for example :
int i;
for(i=0;i<3;i++)
printf("%.*s%s\n", i, " ", “########”);
return 0;
// Cycle three times
Do not output spaces for the first time , Direct output ########
Output a space for the second time , Then the output ########
Output two spaces for the third time , Then the output ########
边栏推荐
猜你喜欢
JS get the height and width corresponding to the box model (window.getcomputedstyle, dom.getboundingclientrect)
Kubernetes understands kubectl/ debugging
Jaspersoft studio installation
15 -- 最接近原点的 K 个点
Uniapp cloud packaging app
90 后眼中的理想 L9:最简单的产品哲学,造最猛的爆款 | 指南斟
Using Sphinx to automatically generate API documents from py source files
Common dynamic memory errors
Std:: vector minutes
ffmpeg protocol concat 进行ts流合并视频的时间戳计算及其音画同步方式一点浅析
随机推荐
Source code analysis of zeromq lockless queue
Golang channel reading data
分饼干问题
90 后眼中的理想 L9:最简单的产品哲学,造最猛的爆款 | 指南斟
Go closure usage example
Remove interval (greedy)
Add the resources directory under test in idea
Master XSS completely from 0 to 1
Extend JS copy content to clipboard
Common dynamic memory errors
Function of getinstance() method
【中國海洋大學】考研初試複試資料分享
Usage of qlist
AB string interchange
14 -- validate palindrome string II
[untitled] PTA check password
Mining procedure processing
What moment makes you think there is a bug in the world?
For the first time in China, Chinatelecom 5g underground personnel positioning project is officially commercial: it can track the position in real time to ensure operation safety
One question per day,