tooltiperror
Super Moderator
- Reaction score
- 231
I'm writing a utility [LJASS]entab[/LJASS]. I'm compiling it with gcc.
entab takes input. Because tabs are 8 cells wide, it replaces eight spaces with [LJASS]"\t"[/LJASS]. But it's... not working. I run it like this:
It's just working correct. I've tried modifying it a lot but it's not working. Any help?
entab takes input. Because tabs are 8 cells wide, it replaces eight spaces with [LJASS]"\t"[/LJASS]. But it's... not working. I run it like this:
JASS:
$ gcc -o entab entab.c
$ ./entab
> a a
a a
> a a
a a
It's just working correct. I've tried modifying it a lot but it's not working. Any help?
Code:
#include <stdio.h>
int main()
{
int c, spaces;
spaces = 0;
while ((c = getchar()) != EOF) {
if (c == ' ') {
spaces++;
if (spaces == 8) {
putchar('\t');
spaces = 0;
}
}
else {
for ( ; spaces != 0; spaces-- ) {
putchar(' ');
}
putchar(c);
}
}
return 0;
}