pointers - What is the size and lifetime of a node in a linked-list implementation in C? -


in linked-list implementation in c (or c++), size of node , lifetime of pointer variable? example:

struct node {   int data;   struct node *next; }*ptr=null; 

now want know size of node: 4 bytes, , if so, how? secondly, how long pointer live: throughout execution of program? lastly, proper call *ptr instance variable or data member or object?

sizeof compile time operation . node structure . size of node summation of members size in structure . u have integer , pointer . size of node size of integer + size of pointer . lifetime : memory allocated dynamically . until call free , node lives . if u perform delete operation , programmer style used free memory allocated node .


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -