TabToSpaces

/*
 * Name: TabToSpaces.c
 * Function: Change a tab to five spaces.
 * Created on: 2009-12-29
 * Programming Language: C
 * Operating system: Window XP
 * Environment: DEV-C++
 * Author: http://blog.csdn.net/programs
 */
 
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
     char ch = 0;
     FILE *infile;
     FILE *outfile;
     infile = fopen(".\\app.c", "r+");
     outfile = fopen(".\\target.c", "a+");
     if (!infile || !outfile)
     {
          printf("Open error\n");
          exit(-1);
     }
     while ((ch = getc(infile)) != EOF)
     {
          if ('\t' == ch)
          {
               fputs("     ", outfile);
          }
          else
          {
               putc(ch, outfile);
          }
     }
    
     close(infile);
     close(outfile);
     return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章