Merge pull request #61 from phuvp/master
C implementation of tabs-to-spaces
Esse commit está contido em:
+32
@@ -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;
|
||||||
|
}
|
||||||
Referência em uma Nova Issue
Bloquear um usuário