The basic thing is to create a node. It can be done by using the malloc function.start = (node*) malloc(sizeof(node))
This statement creates the starting node of list. A block of memory whose size is equal to the sizeof(node) is allocated to the node pointer start. Typecasting is used because otherwise malloc will return pointer to character.
code snippet to create a node.
Self-referential structure emp is defined and is named as node. Two pointers, ‘start’ and ‘temp’ are defined and initially assigned a NULL value.
A value for e_no is accepted. e_no entered as -1, is decided to be the terminating condition for creating nodes. It is checked if starting node is to be created or further nodes are to be created. If value of start pointer is NULL, it means starting node does not exist and is to be created. Memory is assigned to start pointer. Value of e_no is assigned to its e_no field and self-referential pointer assigned a value of NULL.
If value of start pointer is not null, it means start pointer exists and further node is to be created which is created in the same manner.
As new nodes are created start pointer is kept fixed while temp pointer is moved.
C Related Interview Questions
|DBMS Interview Questions||C++ Interview Questions|
|C & Data Structures Interview Questions||Java Interview Questions|
|Go (programming language) Interview Questions||F Sharp (programming language) Interview Questions|
|C preprocessor Interview Questions||R Programming language Interview Questions|
|D Programming Language Interview Questions||Lua (programming language) Interview Questions|
|Embedded C Interview Questions|
Introduction To C-programming
Data Types And Storage Classes
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.