RAD Studio |  |

free

Header File

alloc.h, stdlib.h

Category

Memory Routines

Prototype

void free(void *block);

Description

Frees allocated block.

free deallocates a memory block allocated by a previous call to calloc, malloc, or realloc.

Return Value

None.

Example

Copy Code

    #include <string.h>
    #include <stdio.h>
    #include <alloc.h>
    int main(void)
    {
       char *str;
       /* allocate memory for string */
       str = (char *) malloc(10);
       /* copy "Hello" to string */
       strcpy(str, "Hello");
       /* display string */
       printf("String is %s\n", str);
       /* free memory */
       free(str);
       return 0;
    }

Portability

POSIX | Win32 | ANSI C | ANSI C++
+ | + | + | +

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!