30.10.2014 Views

o_195h4n6al16jb186b1b2qs7fgssa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

is undefined.<br />

malloc<br />

Description: Allocates memory.<br />

Include: <br />

Prototype: void *malloc(size_t size);<br />

Argument: size number of characters to allocate<br />

Return Value: Returns a pointer to the allocated space if successful; otherwise,<br />

returns a null pointer.<br />

Remarks: mallocdoes not initialize memory it returns.<br />

Example: #include /* for printf, sizeof, */<br />

/* NULL */<br />

#include /* for malloc, free */<br />

int main(void)<br />

{<br />

long *i;<br />

if ((i = (long *)malloc(50 * sizeof(long))) ==<br />

NULL)<br />

printf("Cannot allocate memory\n");<br />

else<br />

{<br />

printf("Memory allocated\n");<br />

free(i);<br />

printf("Memory freed\n");<br />

}<br />

}<br />

Output:<br />

Memory allocated<br />

Memory freed<br />

ldiv (Continued)<br />

Standard C Libraries with Math Functions<br />

2004 Microchip Technology Inc. DS51456B-page 285<br />

mblen<br />

Description: Gets the length of a multibyte character. (See Remarks.)<br />

Include: <br />

Prototype: int mblen(const char *s, size_t n);<br />

Arguments: s points to the multibyte character<br />

n number of bytes to check<br />

Return Value: Returns zero if s points to a null character; otherwise, returns 1.<br />

Remarks: MPLAB C30 does not support multibyte characters with length<br />

for (x = 0; x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!