Advertisement
Unnnamedddd

Untitled

Jan 25th, 2021
1,486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define MAXLEN 10000
  4.  
  5. int getline(char line[], int limit);
  6. void copy(char from[], char to[]);
  7.  
  8. int main()
  9. {
  10.     int len; // длина текущей строки
  11.     int threshold = 7; // порог > 80 символов
  12.     char line[MAXLEN];
  13.     while (1)
  14.     {
  15.         len = getline(line, MAXLEN);
  16.         if (len > threshold)
  17.             printf("%s", line);
  18.     }
  19.  
  20.     return 0;
  21. }
  22.  
  23. int getline(char line[], int limit)
  24. {
  25.     int c, i;
  26.     for(i = 0; i < limit && (c = getchar()) != EOF && c != '\n'; ++i)
  27.         line[i] = c;
  28.     if (c == '\n') {
  29.         line[i] = c;
  30.         ++i;
  31.     }
  32.     line[i] = '\0';
  33.     return i;
  34. }
  35.  
  36. void copy(char from[], char to[])
  37. {
  38.     int i = 0;
  39.     while ((to[i] = from[i]) != '\0')
  40.         ++i;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement