struct node* p is only a declaration, i.e., it only tell the compiler the
type of p and no memory is allocated for it.
Before using p, we need to allocate memory to it... so we do p =
malloc(...).
On Wed, Mar 24, 2010 at 9:16 AM, chitta koushik
koushik.infin...@gmail.comwrote:
malloc returns a
struct are passed by value..not by reference...
On Wed, Mar 24, 2010 at 2:42 AM, aman goyal aman...@gmail.com wrote:
why do we use malloc funtcn to allocate memory for a stuct node variable
pointer..
why dont we simply write struct node p;
instead we do
struct node *p
p=malloc();
how do you retain them if you wanted to form a linked list ?.
if it is a one node you can use it, but if you want multiple nodes, how you
can form a linked list ?.
Context will be lost once returned from the function, if you static you will
have only one copy, how you can make linked list out of
This is because by definition linked lists are dynamic.. If they reside on
stack they cannot be dynamic (extensible in size)
On Wed, Mar 24, 2010 at 2:42 AM, aman goyal aman...@gmail.com wrote:
why do we use malloc funtcn to allocate memory for a stuct node variable
pointer..
why dont we
thanx to all.special one to Sathaiah Dontula ..i got ur point and it is
completely valid..!!!
On Wed, Mar 24, 2010 at 1:37 PM, TurksHead Education
turksheadeducat...@gmail.com wrote:
This is because by definition linked lists are dynamic.. If they reside on
stack they cannot be dynamic
why do we use malloc funtcn to allocate memory for a stuct node variable
pointer..
why dont we simply write struct node p;
instead we do
struct node *p
p=malloc();
any valid reasons for this??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
malloc returns a void pointer to the allocated chunk of memory.
On Wed, Mar 24, 2010 at 2:42 AM, aman goyal aman...@gmail.com wrote:
why do we use malloc funtcn to allocate memory for a stuct node variable
pointer..
why dont we simply write struct node p;
instead we do
struct node *p