- //流程方面与无缓存IO一样
- //主要使用fopen fseek fread fwrite fclose这五个函数
- //具体怎样使用通过 man 查询
- #include <stdio.h>
- #include <stdlib.h>
- #define buf_size 100
- unsigned char buf[buf_size];
- int main(void)
- {
- FILE *src, *dst;
- if(NULL == (src = fopen("./src", "r+")))
- {
- printf("fopen_src\n");
- exit(1);
- }
- if(NULL == (dst = fopen("./dst", "w+")))
- {
- printf("fopen_dst\n");
- exit(1);
- }
- if(-1 == (fseek(src,0,SEEK_SET)))
- {
- printf("fopen_dst\n");
- exit(1);
- }
- size_t real_read;
- while((real_read = fread(buf, buf_size, buf_size, src)) > 0)
- {
- fwrite(buf,buf_size, real_read,dst);
- }
- fclose(src);
- fclose(dst);
- return 0;
- }