Solved

linked list

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

630 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