Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions tabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@

/*
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 main(int argc, char *argv[]) {
File *in = stdin;
int c;
fp = fopen("input.txt", "R");

if(argc == 2) {
fp = fopen("input.txt", "R");

if(fp != NULL)
in = fp;
}

while ((c = fgetc(fp)) != EOF) {
if (c == '\t') {
putchar(' ');
putchar(' ');
putchar(' ');
putchar(' ');
puts(" ");
} else {
putchar(c);
}
}

fclose(fp);
fclose(in);
return 0;
}