查找树,俄罗斯方块,系统编程开始
This commit is contained in:
36
Chapter13/C13-Linux系统编程学习笔记.md
Normal file
36
Chapter13/C13-Linux系统编程学习笔记.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# I/O操作
|
||||
|
||||
输入输出是一切实现的基础。
|
||||
|
||||
标准IO:`stdio`
|
||||
|
||||
系统调用IO(文件IO):`sysio`
|
||||
|
||||
优先使用标准IO,兼容性更好,还有合并系统调用的优势。
|
||||
|
||||
|
||||
|
||||
```c
|
||||
/* stdio */
|
||||
/* FILE类型贯穿始终 */
|
||||
|
||||
FILE *fopen(const c);
|
||||
fclose();
|
||||
|
||||
fgetc();
|
||||
fputc();
|
||||
fgets();
|
||||
fputs();
|
||||
fread();
|
||||
fwrite();
|
||||
|
||||
printf();
|
||||
scanf();
|
||||
|
||||
fseek();
|
||||
ftell();
|
||||
rewind();
|
||||
|
||||
fflush();
|
||||
```
|
||||
|
||||
52
Chapter13/C13-Linux系统编程项目实战.md
Normal file
52
Chapter13/C13-Linux系统编程项目实战.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# 项目前瞻
|
||||
|
||||
基于IPV4的流媒体广播系统。
|
||||
|
||||
|
||||
|
||||
## 项目需求
|
||||
|
||||
需要基于客户机和服务器模型的网络音频广播/点播系统。
|
||||
|
||||
用于语音教室和公共广播。
|
||||
|
||||
分为服务器和客户机,服务器在PC上运行,客户机在PC机或者嵌入式设备。
|
||||
|
||||
服务器可以向局域网内以多播的方式给所有客户机发送数据,客户机自己选择接收数据。
|
||||
|
||||
|
||||
|
||||
## 简要框图
|
||||
|
||||
<img src="https://s2.loli.net/2024/04/25/kpolhzmgBEcSYxM.png"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 参考书目
|
||||
|
||||
1. UNIX环境高级编程(第一版经典,第二版有错误)
|
||||
2. UNIX网络编程
|
||||
3. TCP/IP详解(卷一)
|
||||
4. 深入理解计算机系统
|
||||
|
||||
|
||||
|
||||
## 知识网络
|
||||
|
||||
- I/O操作(参考书目1:3,5章,14章非阻塞IO)
|
||||
- 文件系统(参考书目1:4,6,7章)
|
||||
- 并发(信号10章,多线程10,11章)
|
||||
- IPC(进程间通信,8章进程基础,13章守护进程)
|
||||
- 进程间通信(15,16章)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. 弃用root用户
|
||||
2. 重构
|
||||
3. 课堂重点:项目,课堂代码,面试题,实验性题目,推荐书籍的课后题
|
||||
29
Chapter13/io/stdio/fopen.c
Normal file
29
Chapter13/io/stdio/fopen.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen("tmp", "r");
|
||||
if (NULL == fp)
|
||||
{
|
||||
// fprintf(stderr, "fopen() failed! errno = %d\n", errno);
|
||||
// out: fopen() failed! errno = 2
|
||||
/* errno:定义路径 /usr/include/asm-generic/errno-base.h */
|
||||
|
||||
// perror("fopen()");
|
||||
// out: fopen(): No such file or directory
|
||||
|
||||
fprintf(stderr, "fopen(): %s\n", strerror(errno));
|
||||
// out: fopen(): No such file or directory
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
puts("OK!");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user