Advertisement
InnadrilCastle

detab.c

Jan 11th, 2022
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define TABSIZE 8
  4.  
  5. int main(void) {
  6.         int i = 0;
  7.         int c;
  8.  
  9.         while ((c = getchar()) != EOF) {
  10.                 if (c == '\t') {
  11.                         while (i < TABSIZE) {
  12.                                 putchar(' ');
  13.                                 i++;
  14.                         }
  15.                         i = 0;
  16.                 }
  17.                 else {
  18.                         putchar(c);
  19.                         if (c == '\n')
  20.                                 i = 0;
  21.                         else {
  22.                                 i++;
  23.                                 if (i >= TABSIZE)
  24.                                         i = 0;
  25.                         }
  26.                 }
  27.         }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement