beautypg.com

Realloc, Scanf, Realloc scanf – Zilog EZ80F916 User Manual

Page 378

background image

UM014423-0607

C Standard Library

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

358

realloc

Changes the size of the object pointed to by ptr to the size specified by

size

. The contents

of the object are unchanged up to the lesser of the new and old sizes. If ptr is a null pointer,
the

realloc

function behaves like the

malloc

function for the specified size. Otherwise,

if ptr does not match a pointer earlier returned by the

calloc

,

malloc

, or

realloc

func-

tion, or if the space has been deallocated by a call to the

free

or

realloc

function, the

behavior is undefined. If the space cannot be allocated, the

realloc

function returns a

null pointer and the object pointed to by ptr is unchanged. If size is zero, the

realloc

function returns a null pointer and, if ptr is not a null pointer, the object it points to is freed.

Synopsis

#include
void *realloc(void *ptr, size_t size);

Returns

Returns a pointer to the start (lowest byte address) of the possibly moved object.

Example

char *buf;
buf=(char *) malloc(40*sizeof(char));
buf=(char *) realloc(buf, 80*sizeof(char));
if(buf !=NULL)

/*success*/

else

/*fail*/

scanf

Reads input from the stream pointed to by stdin, under control of the string pointed to by
format that specifies the admissible input sequences and how they are to be converted for
assignment, using subsequent arguments as pointers to the object to receive the converted
input. If there are insufficient arguments for the format, the behavior is undefined. If the
format is exhausted while arguments remain, the excess arguments are evaluated but oth-
erwise ignored.

The format is composed of zero or more directives from the following list:

one or more white-space characters

an ordinary character (not %)

a conversion specification

Each conversion specification is introduced by the character %. After the %, the following
appear in sequence:

An optional assignment-suppressing character *.

This manual is related to the following products: