Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

linked list

Posted on 1998-09-09
2
Medium Priority
?
186 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 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

Independent Software Vendors: 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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Suggested Courses

916 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