当前位置:网站首页>Learning diary 3- input and output of data
Learning diary 3- input and output of data
2022-07-20 08:33:00 【Astray King】
Character output function putchar
1.putchar()
2. Function return value : Output characters
3. The functionality : Display a character
Format output function printf
1.printf(" Format symbol ", Output variables );
2. Format symbol
Format symbol | effect |
i,d | Decimal integer |
x,X | Hexadecimal unsigned integer |
o | Octal unsigned integer |
u | An unsigned decimal integer |
c | Single character |
s | character string |
e,E | character string |
f | Floating point decimal in exponential form |
g | e,f The shorter one |
%% | The percent sign itself |
3. Modifier
Modifier | function |
m | The output data field is wide , Data length <m, Left padding ; Otherwise, press the actual output |
.n | For real numbers , Specify the number of digits after the decimal point ( rounding ); Specify the actual number of output bits for the string |
- | The output data is left aligned in the field |
+ | Specifies that a positive sign is displayed before the positive number of signed numbers |
0( Numbers ) | When the output value is specified, the empty position not used on the left side will be filled in automatically 0 |
# | In octal and 16 Show leading before hexadecimal number 0,0x |
l | stay d,o,x,u front , Specify the output precision as long type |
stay e,f,g front , Specify the output precision as double type | |
4. Escape character
Escape character | function |
\b | Backspace , Move the current position to the previous column |
\n | Line break , Moves the current position to the beginning of the next line |
\t | Horizontal TAB ( Skip to the next tab Location ) |
\r | enter , Move the current position to the beginning of the line |
\" | Represents a double quotation mark |
\\ | Represents a backslash character ‘\’ |
Character input function getchar
1.getchar(); Read a character on the keyboard , When the returned value int type , Corresponding to a letter ascii value .
Format input function scanf
1.getchar Only one character data can be read from the keyboard , If you expect to read several data , And of any type , use scanf(" Format controller ", The input variable ); Be careful “%c” As a formatter , Spaces and escape characters can be entered as valid characters .
2. Modifier
Modifier | function |
h | be used for d,o,x front , Specify input as short type |
l | be used for d,o,x front , Designated as long type , be used for e,f, Designated as double type |
m | Specify the input data width , End with a space or a non convertible character |
* | Suppressor , Specify that the input item is not assigned to the variable after reading |
3. When entering data , In case of space enter tab illegal input End of width All represent the end of data .
String output function puts
String input function gets
Program exercises
1. Enter three numbers , After comparing the size, press output from large to small .
2. Enter a character , Output its upper or lower case
3. Solving a quadratic equation of one variable
4. Input a,b Two Numbers , take a Binary form of from low to high b Location 1
边栏推荐
- Dynamic memory management
- 学习日记5-C语言函数的应用
- 基数排序(桶排序)
- Character functions and string functions
- 学习日记6-数组
- [Day.2]约瑟夫环问题,如何用数组代替循环链表(详解)
- ZABBIX agent adds a user-defined monitoring item -- Ping to destination IP link monitoring
- Using function pointer array to write calculator
- Eight queens problem, second understand recursive backtracking (illustrated | C language)
- Yolov5 realizes smoking behavior detection
猜你喜欢
ListView的item展开后完整显示
数据的表示和运算
Recursive backtracking - maze walking
Chapter 62: blue screen crash when running vs program on win10
Pytorch target detection data processing (II) extracting difficult samples, low AP samples
C language program environment and preprocessing
第六十二篇:win10上运行VS程序出现蓝屏崩溃
动态内存申请
YOLOv5苹果香蕉检测
【学习笔记】Unreal(虚幻)4引擎入门(四)
随机推荐
Pytorch target detection data processing (II) extracting difficult samples, low AP samples
Pytorch implements the use of data enhancement classification evaluations
Function recursion in C program
学习日记4-程序结构和控制语句
C language program environment and preprocessing
C语言实现基础版扫雷
steam文件夹移动后游戏需要重新安装怎么办
Path in sword finger offer matrix
第五十九篇:main.c:62:9: note: use option -std=c99 or -std=gnu99 to compile your code
yolov3的权重文件和预训练文件
Yolov5 realizes flame and smoke detection
YOLOv5实现吸烟行为检测
The project is lost after Jenkins restarts (including the download address of Jenkins plugins)
编程实现猜密码游戏
[Day.2]约瑟夫环问题,如何用数组代替循环链表(详解)
ListView的item展开后完整显示
Linear structure understanding
仿联系人的排序
Data tower problem and deformation
珍惜时间,提高效率