zoukankan      html  css  js  c++  java
  • 标准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]

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

  • 相关阅读:
    jquery下拉菜单打开的同时,同行右边的图标变化
    echarts引入及应用
    好用又美观的时间控件
    C#不支持此安全协议
    python re模块中的函数
    python中的收集参数
    python常用操作符
    python 字符串中常用的内置函数
    VS2012停止工作解决办法
    Jqurey图片放大镜插件
  • 原文地址:https://www.cnblogs.com/lanbofei/p/9558322.html
Copyright © 2011-2022 走看看