puts.c 420 Bytes
Newer Older
1
/*
2
 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
9
10
11
 */

#include <stdio.h>

int puts(const char *s)
{
	int count = 0;
12
13
14
15
	while(*s) {
		if (putchar(*s++) == EOF)
			return EOF;
		count++;
16
	}
17
18
19
20

	/* According to the puts(3) manpage, the function should write a
	 * trailing newline.
	 */
21
22
	if (putchar('\n') == EOF)
		return EOF;
23

24
	return count + 1;
25
}