新增了文档目录,并且写了一点第三节

This commit is contained in:
lzy
2024-03-18 14:31:44 +08:00
parent 96ee4eb84e
commit ad3056a8b8
4 changed files with 160 additions and 49 deletions

View File

@@ -0,0 +1,32 @@
# 目录
- [目录](#目录)
- [第三章 输入输出专题](#第三章-输入输出专题)
- [内容](#内容)
- [格式化输入输出函数](#格式化输入输出函数)
# 第三章 输入输出专题
input & output -> I/O(标准IO文件IO)
## 内容
1. 格式化输入输出函数:`scanf`,`printf`
2. 字符输入输出函数:`getchar`,`putchar`
3. 字符串输入输出函数:`gets(!)``puts`
## 格式化输入输出函数
![标准输出格式字符](https://s2.loli.net/2024/03/18/OMiu6CUDZy5RH3P.png)
![标准输出修饰符](https://s2.loli.net/2024/03/18/Z6gVaw1AOJ87Uil.png)
```c
int printf(const char *format, ...);
format: "%【修饰符】格式字符"
```

49
Chapter3/IO/printf.c Normal file
View File

@@ -0,0 +1,49 @@
#include <stdio.h>
#include <stdlib.h>
/***
* printf("%[修饰符]格式字符", 输出表项);
*
*/
#define STRSIZE 10
int main()
{
// printf("hello world\n");
// char ch = 65;
// printf("%c\n", ch);
// out: A
int i = 255;
float f = 123.45678;
char str[STRSIZE] = "helloworld";
double dou = 123.456;
long long l = 123456;
// printf("f = %8.1f\n", f);
// out:f = 123.5
// printf("i = %2d\n", i);
// out: i = 123
// printf("%-10.5s[over]\n", str);
// printf("%+10.5s[over]\n", str);
// out:
// hello [over]
// hello[over]
// 同样对于i进行八进制核对十六进制的输出
// printf("i = %#o\n", i);
// out: i = 0377
// printf("i = %#x\n", i);
// out: i = 0xff
// printf("dou = %lf\n", dou);
// printf("l = %ld\n", l);
// out:
// dou = 123.456000
// l = 123456
exit(0);
}