Guest User

Untitled

a guest
May 26th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void seccionar(char to[], char from[])
  4. {
  5. int a = 0,b = 0, i = 0;
  6. int max = 0;
  7.  
  8. while(from[i] != ''){
  9. if(max <= 80)
  10. to[a] = from[i];
  11. if(max == 80){
  12. if(to[a] == ' ')
  13. to[a] = 'n';
  14. else {
  15. for(;to[a] != ' '; --a)
  16. ++b;
  17. to[a] = 'n';
  18. max = 0;
  19. a = a + b;}
  20. b = 0;
  21. }
  22. ++a;
  23. ++i;
  24. ++max;}
  25. to[a] = '';
  26. }
  27. int getline(char s[])
  28. {
  29. int c, i;
  30.  
  31. for(i=0; (c=getchar()) != EOF; ++i){
  32. s[i] = c;
  33. if(c == 'n')
  34. break;}
  35. ++i;
  36. s[i] = '';
  37. return i;
  38. }
  39. int main()
  40. {
  41. char from[10];
  42. char to[10];
  43. while(getline(from) > 1){
  44. seccionar(to, from);
  45. printf("%s", to);}
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment