标签:des style blog color os io 文件 2014
/** *@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\n",pos ); fputc(‘W‘,fp);*/ fseek(fp,4,SEEK_SET); fputs("Hello,my name is cody wu\nwhat‘s your name\n",fp); fclose(fp); return 0; }
标签:des style blog color os io 文件 2014
原文地址:http://www.cnblogs.com/cody1988/p/3901155.html