Merge pull request #61 from phuvp/master

C implementation of tabs-to-spaces
Esse commit está contido em:
Winnie
2016-06-03 00:04:39 -05:00
+32
Ver Arquivo
@@ -0,0 +1,32 @@
// takes in a file, replaces tabs with four spaces
/*
TODO
- improve the repeated putchar(' ');
- use stdin instead of a file for input
- error handling...
PULL REQUESTS ARE WELCOME!
*/
#include <stdio.h>
int main() {
File *fp;
int c;
fp = fopen("input.txt", "R");
while ((c = fgetc(fp)) != EOF) {
if (c == '\t') {
putchar(' ');
putchar(' ');
putchar(' ');
putchar(' ');
} else {
putchar(c);
}
}
fclose(fp);
return 0;
}