当前位置:网站首页>C language input and output (printf and scanf functions, putchar and getchar functions)
C language input and output (printf and scanf functions, putchar and getchar functions)
2022-04-23 17:57:00 【Chshyz】
printf and scanf function 、putchar and getchar function
Input and output operations are performed by C Functions in the standard function library , Use preprocessing instructions at the beginning of the program file #include Put relevant documents in this procedure #include<stdio.h>
One 、printf() Output details :printf( Format control , Output table columns )
- Format control is a string enclosed in double quotation marks . Abbreviation format string , for example :“%d”.
- The output list is some data that the program needs to output , It can be a constant 、 Variable or table , for example a.
#include<stdio.h>
int main(){
printf("ddddd\n");
}
~
[[email protected] c]# ./printf
ddddd
#include<stdio.h>
int main(){
int a = 100;
printf("%d\tdddd\n",a); // \t There are four spaces
}
~
[[email protected] c]# ./printf
100 dddd
#include<stdio.h>
int main(){
int a = 100;
printf("%d,%d,%d\n",a,a,a++);
}
[[email protected] c]# ./printf
101,101,100
#include<stdio.h>
int main(){
int a = 100;
printf("%d,%d,%d\n",a,a++,a++);
}
[[email protected] c]# ./printf
102,101,100
#include<stdio.h>
int main(){
int a = 100;
printf("%d,%d,%d\n",a,a,++a);
}
[[email protected] c]# ./printf
101,101,101
Two 、scanf() Enter details :scanf(% Format characters , Variable address )
#include<stdio.h>
int main(){
int a;
scanf("%d",&a);
}
[[email protected] c]# ./scanf
2
#include<stdio.h>
int main(){
int a, b;
scanf("%d,%d",&a,&b);
printf("%d,%d\n",a,b);
}
[[email protected] c]# ./scanf
2,3
2,3
3、 ... and 、getchar() and putchar(), Input and output single characters .
- putchar() Output ( Anyone who ASCLL You can put any size ).
#include<stdio.h>
int main(){
char chshyz = 97;
putchar(chshyz);
return 0;
}
~
[[email protected] c]# ./putchar
a
- getchar() Input , It has no parameters .
#include<stdio.h>
int main(){
char chshyz;
chshyz = getchar();
printf("%c\n",chshyz);
return 0;
}
~
[[email protected] c]# ./getchar
chshyz
c
PS: Count the number of upper and lower case letters of the input string ( One letter circulates once )
#include<stdio.h>
int main(){
char chshyz;
int small = 0;
int big = 0;
int i = 0;
for(chshyz = getchar(); chshyz!='\n';){
if (chshyz >= 'a' && chshyz <= 'z') // The comparison is ASCLL code
small++;
else if (chshyz >= 'A' && chshyz <= 'Z')
big++;
chshyz = getchar();
i++;
printf(" The first %d Secondary cycle \n", i);
}
printf(" A lowercase letter :%d individual \t Capitalization :%d individual \n", small, big);
return 0;
}
~
[[email protected] c]# ./getchar
Chshyz
The first 1 Secondary cycle
The first 2 Secondary cycle
The first 3 Secondary cycle
The first 4 Secondary cycle
The first 5 Secondary cycle
The first 6 Secondary cycle
A lowercase letter :5 individual Capitalization :1 individual
版权声明
本文为[Chshyz]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230547413515.html
边栏推荐
- vite配置proxy代理解决跨域
- Open source key component multi_ Button use, including test engineering
- Error in created hook: "referenceerror:" promise "undefined“
- 239. Maximum value of sliding window (difficult) - one-way queue, large top heap - byte skipping high frequency problem
- Sword finger offer 03 Duplicate number in array
- YOLOv4剪枝【附代码】
- Cross domain settings of Chrome browser -- including new and old versions
- Thirteen documents in software engineering
- [binary number] maximum depth of binary tree + maximum depth of n-ary tree
- Hcip fifth experiment
猜你喜欢
关于gcc输出typeid完整名的方法
The JS timestamp of wechat applet is converted to / 1000 seconds. After six hours and one day, this Friday option calculates the time
Romance in C language
String function in MySQL
Applet learning notes (I)
Click Cancel to return to the previous page and modify the parameter value of the previous page, let pages = getcurrentpages() let prevpage = pages [pages. Length - 2] / / the data of the previous pag
JS high frequency interview questions
C1小笔记【任务训练篇一】
102. Sequence traversal of binary tree
Gaode map search, drag and drop query address
随机推荐
SQL optimization for advanced learning of MySQL [insert, primary key, sort, group, page, count]
Laser slam theory and practice of dark blue College Chapter 3 laser radar distortion removal exercise
2022 Jiangxi energy storage technology exhibition, China Battery exhibition, power battery exhibition and fuel cell Exhibition
2022年广东省安全员A证第三批(主要负责人)特种作业证考试题库及在线模拟考试
ROS package NMEA_ navsat_ Driver reads GPS and Beidou Positioning Information Notes
2022年上海市安全员C证操作证考试题库及模拟考试
Operation of 2022 mobile crane driver national question bank simulation examination platform
高德地图搜索、拖拽 查询地址
Kubernetes 服务发现 监控Endpoints
Go语言JSON包使用
Oil monkey website address
Gaode map search, drag and drop query address
209. Minimum length subarray - sliding window
QTableWidget使用讲解
Cloud native Virtualization: building edge computing instances based on kubevirt
102. Sequence traversal of binary tree
JS implementation private attribute
Element calculation distance and event object
Land cover / use data product download
String function in MySQL