Advertisement
Guest User

Untitled

a guest
Jul 29th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define EOL '\n'
  5. #define TAB '\t'
  6. #define SPACE ' '
  7. #define TABSTOP 4
  8.  
  9. int main() {
  10.     int n = 0;
  11.  
  12.     while(1) {
  13.         int c = getchar();
  14.  
  15.         if(c == EOF) {
  16.             break;
  17.         }
  18.  
  19.         if(c == EOL) {
  20.             putchar(c);
  21.             n = 0;
  22.  
  23.             continue;
  24.         }
  25.  
  26.         if(c == TAB) {
  27.             while(n < TABSTOP) {
  28.                 putchar(SPACE);
  29.                 n++;
  30.             }
  31.  
  32.             if(n >= TABSTOP) {
  33.                 n = 0;
  34.             }
  35.  
  36.             continue;
  37.         }
  38.  
  39.         putchar(c);
  40.         n++;
  41.  
  42.         if(n >= TABSTOP) {
  43.             n = 0;
  44.         }
  45.     }
  46.  
  47.     return EXIT_SUCCESS;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement