/* John Pfeiffer, 22Jun08 replace all tab characters (/t) with 4 spaces in an ascii text file */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[])
{
char c;
char outputfile[128]="notabs-";
FILE* ifp;
FILE* ofp;
ifp = fopen(argv[1],"r");
strcat(outputfile, argv[1]);
ofp = fopen(outputfile,"w");
if( (ifp == NULL) || (ofp == NULL))
{ printf("\nERROR opening file, try tab-to-spaces.exe filename.txt\n");
exit(1);
}
c = getc(ifp);
while( c!= EOF)
{
if( c == '\t')
{ putc(' ',ofp);
putc(' ',ofp);
putc(' ',ofp);
putc(' ',ofp);
}
else
{ putc(c,ofp);
}
c = getc(ifp);
}
fclose(ifp);
return 0;
}