Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

linked list

Posted on 1998-09-09
2
Medium Priority
?
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use structures 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.

719 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