beautypg.com

Gets – Zilog Z8F0130 User Manual

Page 465

background image

UM013037-1212

gets

Zilog Developer Studio II – Z8 Encore!

User Manual

441

Returns

The next character from the input stream pointed to by stdin. If the stream is at end-of-file,
the end-of-file indicator for the stream is set and

getchar

returns EOF. If a read error

occurs, the error indicator for the stream is set, and

getchar

returns EOF.

Example

int i;

i=getchar();

The UART must be initialized using the Zilog

init_uart()

function. See the

init_uart

section on page 232.

gets

Reads characters from a UART into the array pointed to by

s

, until end-of-file is encoun-

tered or a new-line character is read. The new-line character is discarded and a null char-
acter is written immediately after the last character read into the array.

Synopsis

#include

char *gets(char *s);

Returns

The value of

s

if successful. If a read error occurs during the operation, the array contents

are indeterminate, and a null pointer is returned.

Example

char *r;

char buf [80];

r=gets(buf);

if (r==NULL)

/*No input*/

The UART must be initialized using the Zilog

init_uart()

function. See the

init_uart

section on page 232.

Note:

Note: