Advertisement
Guest User

Untitled

a guest
May 30th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. /*
  2. ** hello.c for source in /home/admin/Documents/Programming/hello/source
  3. **
  4. ** Made by Thomas Murgia
  5. ** Login <garuda1@protonmail.com>
  6. **
  7. ** Started on Mon May 30 19:09:11 2016 Thomas Murgia
  8. ** Last update Mon May 30 19:09:11 2016 Thomas Murgia
  9. */
  10.  
  11. #include <sys/types.h>
  12. #include <unistd.h>
  13.  
  14. #define STDIN 0
  15. #define STDOUT 1
  16. #define STDERR 2
  17.  
  18. #define SUCCESS 0
  19. #define FAILURE 1
  20.  
  21. size_t my_putc(const char c)
  22. {
  23. if (write(STDOUT, &c, 1))
  24. return (0);
  25. return (1);
  26. }
  27.  
  28. size_t my_puts(const char *str)
  29. {
  30. size_t i;
  31.  
  32. if (str == NULL)
  33. return (FAILURE);
  34. i = 0;
  35. while (*(str + i) != '\0')
  36. my_putc(str[i++]);
  37. return (i);
  38. }
  39.  
  40. int main(int argc, char **argv)
  41. {
  42. my_puts("Hello, world!\n");
  43. return (SUCCESS);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement