回覆列表
  • 1 # 不冷的臥

    #include <stdlib.h>#include <stdio.h>#define Line 1024int main(){ //檔名及檔案指標 char infile[]="D:\\Wtmp\\1.txt"; char outfile[]="D:\\Wtmp\\2.txt"; FILE *fpi,*fpo; //暫存器 char *outbuf; outbuf = (char *)malloc(Line*sizeof(char)); if( ( fpi=fopen(infile,"r") ) == NULL ) { printf("檔案開啟%s失敗\n",infile); return 3; } if( ( fpo=fopen(outfile,"w") ) == NULL ) { printf("檔案開啟%s失敗\n",outfile); return 3; } while(1) { //outbuf要乾淨 //memset(outbuf,0,Line); outbuf=0; fprintf(fpo,"%s",outbuf); if (fgets(outbuf,Line,fpi)==NULL) { break; }//全部行結束退出迴圈 //DelStr(outbuf,"刪除字串"); //過載函式DelStr //DelStr(outbuf,"要替換字串","替換成字串"); //過載函式DelStr fprintf(fpo,"%s",outbuf); } //關閉檔案 free(outbuf); fclose(fpi); fclose(fpo); return 0;}

  • 中秋節和大豐收的關聯?
  • suv和轎車那個比較好開,感覺一樣嘛?