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;
}

你可能感兴趣的:(职场,休闲,TabToSpaces)