Advertisement
k3rsowa

txt→txt

Sep 6th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include    <stdio.h>
  2. #include    <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6.     FILE    *fin,*fout;
  7.     char    infile[40],outfile[40],s[256];
  8.    
  9.     printf("入力ファイル名=");
  10.     gets(infile);
  11.     printf("出力ファイル名=");
  12.     gets(outfile);
  13.     if( (fin=fopen(infile,"r"))==NULL) {            /* 入力ファイルオープン */
  14.         printf("入力ファイルがオープンできません\n");
  15.         exit(EXIT_FAILURE);
  16.     }
  17.     if( (fout=fopen(outfile,"w"))==NULL) {          /* 出力ファイルオープン */
  18.         printf("出力ファイルがオープンできません\n");
  19.         exit(EXIT_FAILURE);
  20.     }
  21.     while(fgets(s,256,fin)!=NULL) {     /* 入力ファイルから読み込んだデータを  */
  22.         fputs(s,fout);          /*         出力ファイルに書き込み    */
  23.     }
  24.     fclose(fin);                        /* 入力ファイルクローズ */
  25.     fclose(fout);                       /* 出力ファイルクローズ */
  26.    
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement