malloc()
• On execution of malloc() function, the memory is allocated to local variable.
• This memory is taken form free pool.
• The parameter for malloc() is an integer that specifies the number of bytes needed.
• The prototype of this function is in header file alloc.h, stdlib.h
• Syntax:
void *malloc(size n);
• This returns a pointer to n bytes of un-initialized storage or NULL if the request can not be satisfied.
• Example:
char *string;
string = malloc(n);
• In above statement, a string of type char* is declared where n is the variable containing number of bytes needed.
• On execution of malloc() function, the memory is allocated to local variable.
• This memory is taken form free pool.
• The parameter for malloc() is an integer that specifies the number of bytes needed.
• The prototype of this function is in header file alloc.h, stdlib.h
• Syntax:
void *malloc(size n);
• This returns a pointer to n bytes of un-initialized storage or NULL if the request can not be satisfied.
• Example:
char *string;
string = malloc(n);
• In above statement, a string of type char* is declared where n is the variable containing number of bytes needed.
No comments:
Post a Comment