当前位置:网站首页>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 ########
边栏推荐
- 电源自动测试系统NSAT-8000,精准高速可靠的电源测试设备
- QT loading third-party library basic operation
- ffmpeg protocol concat 进行ts流合并视频的时间戳计算及其音画同步方式一点浅析
- Go语言Zap库Logger的定制化和封装使用详解
- HMS Core机器学习服务实现同声传译,支持中英文互译和多种音色语音播报
- Modal and modeless dialogs for QT
- Introduction to flexible array
- dev/mapper的解释
- Gif动图如何裁剪?收下这个图片在线裁剪工具
- Learning notes on February 8, 2022 (C language)
猜你喜欢

【中國海洋大學】考研初試複試資料分享

使用sphinx根据py源文件自动生成API文档

【Try to Hack】vulhub靶场搭建

Judging the number of leap years from 1 to N years

SPARQL learning notes of query, an rrdf query language

15 -- 最接近原点的 K 个点

About the problem of kicad stuck in win10 version, version 6 x

【Try to Hack】vulnhub DC1

Gif动图如何裁剪?收下这个图片在线裁剪工具

Iterator failure condition
随机推荐
[try to hack] vulhub shooting range construction
Luogu p5707 [deep foundation 2. example 12] late for school
JS to add elements to the header, or tail of an array
Generation method and usage of coredump
Power automatic test system nsat-8000, accurate, high-speed and reliable power test equipment
Biscuit distribution
Daily question, magic square simulation
Uniapp cloud packaging app
Modal and modeless dialogs for QT
Go语言Zap库Logger的定制化和封装使用详解
User defined data type - structure
Is it safe to open a stock account online?
NBD Network Block Device
使用sphinx根据py源文件自动生成API文档
14 -- 验证回文字符串 Ⅱ
Usage of qlist
Design and implementation of thread pool
Real variable instance
How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
NBD Network Block Device