To check the working of Detect_Loop function, i have created a loop for the first time when we add elements at the end.
After then it is fine, and normal again.
I have removed, almost every minute bugs in the program.
In this program you will never get a segmentation fault. Also your program will never terminate undesirably. Even if you enter multiple character at the menu..
==========================================
MAIN MENU
==========================================
1. Create link list
2. Insert elements.
3. Update an element.
4. View the linklist.
5. Delete an element.
6. Find an element.
7. Exit.
8. Detect a loop
Enter your choice:
===========================================
INSERT_MENU
==========================================
1. Insert at the end.
2. Insert at the top.
3. Insert after nth element.
4. Insert after key element.
5. Return to main menu.
6. Exit.
Enter your choice:
====================================================================================================
RCS file: ./linklist.c,v
Working file: ./linklist.c
head: 1.9
branch:
locks: strict
utkarsh: 1.9
access list:
symbolic names:
keyword substitution: kv
total revisions: 9; selected revisions: 9
description:
Completed upto view and insert.
Debugging messages are present in the code.
—————————-
revision 1.9 locked by: utkarsh;
date: 2014/07/20 10:40:07; author: utkarsh; state: Exp; lines: +17 -2
Added an option for restricted view, depends on user to see the number
of elements to be displayed. Reliable in a linklist with a loop within itself.
—————————-
revision 1.8
date: 2014/07/20 10:30:34; author: utkarsh; state: Exp; lines: +113 -78
Added an option of detecting a loop.
Restricted view to 15 elements only.
—————————-
revision 1.7
date: 2014/07/20 06:01:24; author: utkarsh; state: Exp; lines: +92 -13
Some extra bugs removed, which were returning Segmentation Fault on some occassions.
—————————-
revision 1.6
date: 2014/07/19 20:24:54; author: utkarsh; state: Exp; lines: +40 -1
Created the next function, Insertatn().
—————————-
revision 1.5
date: 2014/07/19 19:58:36; author: utkarsh; state: Exp; lines: +84 -18
Made an insert menu. With insert at top, insert at end implemented.
—————————-
revision 1.4
date: 2014/07/19 15:55:46; author: utkarsh; state: Exp; lines: +45 -20
Completed the whole linklist. Garbage code included.
—————————-
revision 1.3
date: 2014/07/19 08:15:25; author: utkarsh; state: Exp; lines: +20 -8
C
Created the function Delete().
—————————-
revision 1.2
date: 2014/07/19 07:20:06; author: utkarsh; state: Exp; lines: +17 -1
Created the update function.
—————————-
revision 1.1
date: 2014/07/19 06:49:54; author: utkarsh; state: Exp;
Initial revision
=============================================================================