C语言 文件操作

/**
*@author cody
*@date 2014-08-09
*@description copy text file
* FILE *fopen(filename,openmode)
* fclose(FILE *stream)
* int fseek(stream,offset,whence)
* long ftell(stream)
* void rewind(stream)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    
    FILE *fp = fopen("file","r+");
    if(fp == NULL){

        perror("open error");
        exit(1);
    }

    /*if(fseek(fp,8,SEEK_SET) != 0){
        perror("seek error");
        exit(0);
    }

    long pos = ftell(fp);
    printf("file current pos = %ld
",pos );

    fputc('W',fp);*/
    fseek(fp,4,SEEK_SET);
    fputs("Hello,my name is cody wu
what's your name
",fp);

    
    
    fclose(fp);


    return 0;
}
原文地址:https://www.cnblogs.com/cody1988/p/3901155.html