Advertisement
Guest User

Untitled

a guest
Oct 20th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. /* ft_putchar.c :+: :+: :+: */
  2. /* +:+ +:+ +:+ */
  3. /* By: pcarre <marvin@42.fr> +#+ +:+ +#+ */
  4. /* +#+#+#+#+#+ +#+ */
  5. /* Created: 2015/08/13 14:42:00 by pcarre #+# #+# */
  6. /* Updated: 2015/08/13 17:43:10 by pcarre ### ########.fr */
  7. /* */
  8. /* ************************************************************************** */
  9.  
  10. #include <unistd.h>
  11.  
  12. void ft_putchar(char c)
  13. {
  14. write(1, &c, 1);
  15. }
  16. /* ************************************************************************** */
  17. /* */
  18. /* ::: :::::::: */
  19. /* ft_putstr.c :+: :+: :+: */
  20. /* +:+ +:+ +:+ */
  21. /* By: pcarre <marvin@42.fr> +#+ +:+ +#+ */
  22. /* +#+#+#+#+#+ +#+ */
  23. /* Created: 2015/08/13 14:43:23 by pcarre #+# #+# */
  24. /* Updated: 2015/08/13 15:47:41 by pcarre ### ########.fr */
  25. /* */
  26. /* ************************************************************************** */
  27.  
  28. void ft_putchar(char c);
  29.  
  30. void ft_putstr(char *str)
  31. {
  32. int i;
  33.  
  34. i = 0;
  35. while (str[i] != '\0')
  36. {
  37. ft_putchar(str[i]);
  38. i++;
  39. }
  40. }
  41. /* ************************************************************************** */
  42. /* */
  43. /* ::: :::::::: */
  44. /* ft_strcmp.c :+: :+: :+: */
  45. /* +:+ +:+ +:+ */
  46. /* By: pcarre <marvin@42.fr> +#+ +:+ +#+ */
  47. /* +#+#+#+#+#+ +#+ */
  48. /* Created: 2015/08/13 14:48:30 by pcarre #+# #+# */
  49. /* Updated: 2015/08/13 16:02:55 by pcarre ### ########.fr */
  50. /* */
  51. /* ************************************************************************** */
  52.  
  53. int ft_strcmp(char *s1, char *s2)
  54. {
  55. int i;
  56.  
  57. i = 0;
  58. while (s1[i] != '\0')
  59. {
  60. if (s2[i] == '\0')
  61. {
  62. return (1);
  63. }
  64. if (s2[i] > s1[i])
  65. {
  66. return (-1);
  67. }
  68. if (s1[i] > s2[i])
  69. {
  70. return (1);
  71. }
  72. i++;
  73. }
  74. if (s2[i] != '\0')
  75. {
  76. return (-1);
  77. }
  78. return (0);
  79. }
  80. /* ************************************************************************** */
  81. /* */
  82. /* ::: :::::::: */
  83. /* ft_strlen.c :+: :+: :+: */
  84. /* +:+ +:+ +:+ */
  85. /* By: pcarre <marvin@42.fr> +#+ +:+ +#+ */
  86. /* +#+#+#+#+#+ +#+ */
  87. /* Created: 2015/08/13 14:36:57 by pcarre #+# #+# */
  88. /* Updated: 2015/08/13 15:35:02 by pcarre ### ########.fr */
  89. /* */
  90. /* ************************************************************************** */
  91.  
  92. int ft_strlen(char *str)
  93. {
  94. int i;
  95.  
  96. i = 0;
  97. while (str[i] != '\0')
  98. {
  99. i++;
  100. }
  101. return (i);
  102. }
  103. /* ************************************************************************** */
  104. /* */
  105. /* ::: :::::::: */
  106. /* ft_swap.c :+: :+: :+: */
  107. /* +:+ +:+ +:+ */
  108. /* By: pcarre <marvin@42.fr> +#+ +:+ +#+ */
  109. /* +#+#+#+#+#+ +#+ */
  110. /* Created: 2015/08/08 23:19:06 by pcarre #+# #+# */
  111. /* Updated: 2015/08/13 15:48:23 by pcarre ### ########.fr */
  112. /* */
  113. /* ************************************************************************** */
  114.  
  115. void ft_swap(int *a, int *b)
  116. {
  117. int temp;
  118.  
  119. temp = *a;
  120. *a = *b;
  121. *b = temp;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement