2 5dc21454 2023-07-14 jrmu * 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?
5 5dc21454 2023-07-14 jrmu #include <stdio.h>
6 5dc21454 2023-07-14 jrmu #define TABSTOP 8
10 5dc21454 2023-07-14 jrmu int c, col, spaces;
12 5dc21454 2023-07-14 jrmu for (col = 1, spaces = 0; (c = getchar())!=EOF; ++col) {
13 5dc21454 2023-07-14 jrmu if (c == ' ') {
14 5dc21454 2023-07-14 jrmu if (col%TABSTOP == 0) {
15 5dc21454 2023-07-14 jrmu printf ("\t");
20 5dc21454 2023-07-14 jrmu } else if (c == '\t') {
22 5dc21454 2023-07-14 jrmu printf(" ");
24 5dc21454 2023-07-14 jrmu } while (col%TABSTOP != 1);
26 5dc21454 2023-07-14 jrmu for (int i = 0; i < spaces; ++i) {
27 5dc21454 2023-07-14 jrmu printf(" ");
30 5dc21454 2023-07-14 jrmu printf("%c", c);
31 5dc21454 2023-07-14 jrmu if (c == '\n') {