fork download
  1. #include <stdio.h>
  2. #define MAXLINE 100
  3.  
  4. int my_getline (char line[], int lim );
  5.  
  6. int main()
  7. {
  8. int lim = MAXLINE;
  9. int len;
  10. char line[MAXLINE];
  11. while ((len = my_getline (line, MAXLINE)) >1)
  12. printf ("%s ", line);
  13. printf ("\n");
  14. return 0;
  15. }
  16. int my_getline (char s[], int lim)
  17. {
  18. int i,c;
  19. for (i=0; i<lim-1 && (c = getchar()) != EOF ; ++i)
  20. {
  21. s[i] = c;
  22. if (s[i] == '\t') s[i] = ' ';
  23. if (s[i-1] == ' ' && s[i] == s[i-1] ) --i;
  24. // if (c == '\n') s[i] = ' ';;
  25. }
  26.  
  27. if (c == '\n') {
  28. s[i] = c;
  29. ++i;}
  30. s[i] = '\0';
  31. return i;
  32. }
  33.  
Success #stdin #stdout 0s 4476KB
stdin
быв
as
asd


stdout
быв
as
asd