Blob
1 /*2 * 1-21. Write a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. When either a tab or a single blank would suffice to reach a tab stop, which should be given preference?3 */5 #include <stdio.h>6 #define TABSTOP 88 main()9 {10 int c, col, spaces;12 for (col = 1, spaces = 0; (c = getchar())!=EOF; ++col) {13 if (c == ' ') {14 if (col%TABSTOP == 0) {15 printf ("\t");16 spaces = 0;17 } else {18 ++spaces;19 }20 } else if (c == '\t') {21 do {22 printf(" ");23 ++col;24 } while (col%TABSTOP != 1);25 } else {26 for (int i = 0; i < spaces; ++i) {27 printf(" ");28 }29 spaces = 0;30 printf("%c", c);31 if (c == '\n') {32 col = 0;33 }34 }35 }36 }