Advertisement
andreafiori

Untitled

Aug 30th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define MAX_LINE 100
  5.  
  6. int detab (string, limit)
  7. char string [];
  8. int limit;
  9. {
  10.     char c;
  11.     int i = 0, j = 0, temp = 0;
  12.  
  13.     for (i = 0; (i < (limit - 1)) && (c = getchar ()) != '\n'; i += 1 + temp)
  14.     {
  15.         if (c != '\n' && c != '\t')
  16.         {
  17.             string [i] = c;
  18.         }
  19.         else if (c == '\t')
  20.         {
  21.             for (j = 0; j < 10; j++)
  22.                 string [i + j] = '-';
  23.             temp += j;
  24.         }
  25.         else
  26.         {
  27.             string [i] = '\0';
  28.         }
  29.     }
  30.  
  31.     return (i + temp);
  32. }
  33.  
  34.  
  35. int main()
  36. {
  37.     char parola [MAX_LINE];
  38.     int lung = 0, i = 0;
  39.  
  40.     while ((lung = detab(parola, MAX_LINE)) > 0)
  41.     {
  42.         for (i = 0; i < lung; i++)
  43.             printf("%c", parola [i]);
  44.         printf("\n");
  45.     }
  46.  
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement