Skip to content

Instantly share code, notes, and snippets.

@mjf
Created October 19, 2011 23:17
Show Gist options
  • Save mjf/1299972 to your computer and use it in GitHub Desktop.
Save mjf/1299972 to your computer and use it in GitHub Desktop.
Possibly the shortest program to expand tabelators to spaces
/**
* 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;
}
@mjf
Copy link
Author

mjf commented Oct 19, 2011

If you know of shorter way, just let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment