puts.c 342 B

123456789101112131415161718192021222324
  1. /*
  2. * Copyright (c) 2013-2018, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdio.h>
  7. int puts(const char *s)
  8. {
  9. int count = 0;
  10. while (*s != '\0') {
  11. if (putchar(*s) == EOF)
  12. return EOF;
  13. s++;
  14. count++;
  15. }
  16. if (putchar('\n') == EOF)
  17. return EOF;
  18. return count + 1;
  19. }