putstr.c 560 B

12345678910111213141516171819202122232425262728293031
  1. /* Assignment name : ft_putstr
  2. Expected files : ft_putstr.c
  3. Allowed functions: write
  4. --------------------------------------------------------------------------------
  5. Write a function that displays a string on the standard output.
  6. The pointer passed to the function contains the address of the string's first
  7. character.
  8. Your function must be declared as follows:
  9. void ft_putstr(char *str); */
  10. #include <unistd.h>
  11. void ft_putstr(char *str)
  12. {
  13. while (*str)
  14. {
  15. write(1, str, 1);
  16. str++;
  17. }
  18. }
  19. int main(void)
  20. {
  21. ft_putstr("Hello World");
  22. return (0);
  23. }