Solved

linked list

Posted on 1998-09-09
2
182 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
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.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

839 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