1-20
Quest: page 34
Write a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns. Should n be a variable or a symbolic parameter ?
- check if c is a tab then put X spaces there instead.
#include <stdio.h>
#define TABSPACE 8
int main() {
int c;
while ((c = getchar()) != EOF) {
if (c == '\t') {
for (int i = 0; i < TABSPACE; i++) {
putchar(' ');
}
} else {
putchar(c);
}
}
}