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

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -