Advertisement
yahiko

main.c

Oct 25th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <unistd.h>
  2. #include "include/my_head.h"
  3.  
  4. int my_strlen_x(char *str)
  5. {
  6. int i;
  7.  
  8. i = 0;
  9. while (str[i] != '\n' && str[i] != '\0')
  10. i++;
  11. return (i);
  12. }
  13.  
  14. int my_strlen_y(char *str)
  15. {
  16. int i;
  17. int j;
  18.  
  19. i = 0;
  20. j = 0;
  21. while (str[i] != '\0')
  22. {
  23. if (str[i] == '\n')
  24. j++;
  25. i++;
  26. }
  27. return (j);
  28. }
  29.  
  30. void my_aff_coord(int colle, int x, int y, int i)
  31. {
  32. if (i > 0)
  33. my_putstr(" || ");
  34. my_putstr("[colle1-");
  35. my_put_nbr(colle);
  36. my_putstr("] [");
  37. my_put_nbr(x);
  38. my_putstr("] [");
  39. my_put_nbr(y);
  40. my_putchar(']');
  41. }
  42.  
  43.  
  44.  
  45. void what_is_this_glue(char *str)
  46. {
  47. int x;
  48. int y;
  49. int i;
  50.  
  51. i = 0;
  52. x = my_strlen_x(str);
  53. y = my_strlen_y(str);
  54. if (my_colle1(str) == 1)
  55. my_aff_coord(1, x, y, i++);
  56. if (i == 0)
  57. {
  58. if (my_colle2(str, x ,y) == 1)
  59. my_aff_coord(2, x, y, i++);
  60. if (my_colle3(str, x, y) == 1)
  61. my_aff_coord(3, x, y, i++);
  62. if (my_colle4(str, x, y))
  63. my_aff_coord(4, x, y, i++);
  64. if (my_colle5(str, x, y))
  65. my_aff_coord(5, x, y, i++);
  66. }
  67. }
  68.  
  69. int main(int ac, char **av)
  70. {
  71. char buff[BUFF_SIZE + 1];
  72. int len;
  73.  
  74. while ((len = read(0, buff, BUFF_SIZE)) > 0)
  75. {
  76. if (len != 0)
  77. {
  78. buff[len] = '\0';
  79. what_is_this_glue(buff);
  80. my_putchar('\n');
  81. }
  82. }
  83. return (0);
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement