LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 07-19-2012, 05:08 AM   #1
batman4
Member
 
Registered: Jul 2012
Posts: 47

Rep: Reputation: Disabled
en-queue linklist in c


pls help i want to insert data from structure into link-list at rear and delete it fro front in c language..
 
Old 07-19-2012, 05:53 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
do you have some code about handling linked lists? (to start with)
 
Old 07-19-2012, 06:20 AM   #3
batman4
Member
 
Registered: Jul 2012
Posts: 47

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
do you have some code about handling linked lists? (to start with)
Code:
struct query{
char data[20];
struct query *next;
};


struct query *head;
struct query *tail;

struct  query *temp=NULL;
if(!temp)
 {malloc
temp->next =NULL;
HEAD =TEMP
TAIL =TEMP;
}
else

now this is confusing me
how to insert a node at rear end
while temp->next !=NULL {
temp=temp->next;
here
 
Old 07-19-2012, 06:34 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,860
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
to-end:
Code:
newelement->next= NULL;
if (!head) {
    head= newelement;
} else {
    tail->next= newelement;
}
tail= newelement;
to-start:
Code:
newelement->next= head;
if (!head) {
    tail= newelement;
}
head= newelement;

Last edited by NevemTeve; 07-19-2012 at 08:31 AM.
 
1 members found this post helpful.
Old 07-20-2012, 11:53 AM   #5
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Please follow this discussion here:
http://www.linuxquestions.org/questi...ic-4175417526/
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any chance to get length of run queue and swap queue? emJ4y Programming 1 11-03-2010 02:13 PM
How to untar my tarred mail queue folder back to the sendmail queue directory again? Md.Abul Quashem Linux - Server 6 02-16-2010 08:32 AM
Is it possible for me to write in front of queue in case of message queue? hemanthv414 Linux - Newbie 1 11-17-2008 04:40 PM
sorted linklist function harrylee2003 Programming 2 08-05-2006 11:04 PM
problem with linklist vijeesh_ep Programming 6 07-31-2004 05:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration