11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Library FunctionsREALLOCSynopsis#include void * realloc (void * ptr, size_t cnt)DescriptionThe realloc() function frees the block of memory at ptr, which should have been obtained by a previouscall to malloc(), calloc() or realloc(), then attempts to allocate cnt bytes of dynamic memory,and if successful copies the contents of the block of memory located at ptr into the new block.At most, realloc() will copy the number of bytes which were in the old block, but if the newblock is smaller, will only copy cnt bytes.Example#include #include #include voidmain (void){char * cp;}cp = malloc(255);if(gets(cp))cp = realloc(cp, strlen(cp)+1);printf("buffer now %d bytes long\n", strlen(cp)+1);See Alsomalloc(), calloc()187

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

Saved successfully!

Ooh no, something went wrong!