标准IO ——将A文件fpd第3个字节之后的内容复制到文件fps

 1 /*
 2  *使用标准IO ——将A文件fpd第3个字节之后的内容复制到文件fps
 3  流程:
 4 1.创建两个流,链接目标文件和源文件
 5 2.输入流的基准点偏移四个单位然后输入缓冲区
 6 3.输出流读取缓冲区数据送入文件
 7 
 8  * */
 9 #include<stdio.h>
10 #include <string.h>
11 
12 int main(){
13     FILE *fps,*fpd;
14     if((fps=fopen("fps.txt","r+"))==NULL){
15     
16         perror("fail to open fps");
17         return -1;
18     }
19     
20     if((fpd=fopen("fpd.txt","w+"))==NULL){
21     
22         perror("fail to open fpd");
23         return -1;
24     }
25     
26     if(fseek(fps,3,SEEK_SET)==EOF){
27     
28         perror("fessk error");
29         return -1;
30     }
31     
32     
33     char buf[64] = {0};
34     while(1){
35         int n;
36         n=fread(buf,1,64,fps);
37         if(n<=0){
38             break;
39         }
40         fwrite(buf,1,n,fpd);
41         memset(buf,sizeof(buf),0);
42 
43     }
44 
45 
46     //fclose(fps);
47     //fclose(fpd);
48 
49     return 0;
50 }

 

错误:

1 linux@ubuntu:~/lianxi/wenjian/wenjian$ gcc biaozunio.c -o biaozunio -Wall
2 biaozunio.c: In function ‘main’:
3 biaozunio.c:13:8: warning: assignment makes pointer from integer without a cast [enabled by default]
4 biaozunio.c:13:2: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

解析:

1 biaozunio.c:在函数'main'中:
2 biaozunio.c:138:警告:赋值从整数中生成没有强制转换的指针[默认启用]
3 biaozunio.c:132:警告:建议用作真值的赋值括号[-Whatarentheses]

优先级错误,==的优先级高于=,在使用中应该有默认添加的习惯;

原文地址:https://www.cnblogs.com/lanbofei/p/9558322.html