Solved

linked list

Posted on 1998-09-09
2
177 Views
Last Modified: 2010-04-15
I have a linked list. i am new to them and i need a method of accessing a specified element. eg: i have entered 10 names into a database program and i need to read the 7th one.. in terms of a linked list, i need to access the 7th element.
thanks
0
Comment
Question by:galdes
2 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 100 total points
ID: 1252616
I'm making some assumptions here. Feel free to ask if they're wrong, or you need more information.

/* A list element containing a pointer to the next one */
struct elm
{   ...
    ...
    struct elm *next;
}

/* a utility pointer */
struct elm *lp;

/* pointer to head of list */
struct elm *head;

int i;

for(i=0,lp=head; i<7; ++i)lp=lp->next;


That's the basic idea.

0
 

Expert Comment

by:choubeyb
ID: 14992299
wap to insert a node at end in linked list

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jquery/ajax to code behind 7 158
Handling string inputs in C/Linux 23 167
C Language combined operators 28 101
Detect CR LF to each line 12 137
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now