Created
October 19, 2011 23:17
-
-
Save mjf/1299972 to your computer and use it in GitHub Desktop.
Possibly the shortest program to expand tabelators to spaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Possibly the shortest program to expand tabelators to spaces | |
* Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/> | |
* Released under the terms of The MIT License. | |
*/ | |
#include <stdio.h> | |
int | |
main(void) | |
{ | |
int c, i = 0; | |
while((c = fgetc(stdin)) != EOF) { | |
switch(c) { | |
case '\t': | |
c = ' '; | |
while(++i % 8) | |
printf(" "); | |
case '\n': | |
i = -1; | |
} | |
i++; | |
printf("%c", c); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you know of shorter way, just let me know.