Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 10-28-2004, 05:05 AM   #1
Registered: Jun 2004
Posts: 51

Rep: Reputation: 15
C program problem on delete duplicated nodes in linked list !

I am writting a function to remove duplicated nodes in linked list

but it run out of memory!!

Any C expert can tell me what error on my code!!

many thx
typedef struct node *NodePtr;

struct node
	int num;
	NodePtr next;
void delete_duplicated_nodes(NodePtr p)
	NodePtr temp_root	= p;
	NodePtr temp_pre	= p;
	NodePtr temp_move	= p->next;

	while(temp_root != NULL){

		while(temp_move != NULL){
			if(temp_move->num == temp_root->num){
				temp_move = temp_move->next;		
				temp_pre->next = temp_move;			
				temp_pre = temp_pre->next;			
				temp_move = temp_move->next;

		temp_root	= temp_root->next;				
		temp_pre	= temp_root->next;				
		temp_move	= temp_root->next->next;		


Last edited by antony_csf; 10-28-2004 at 05:21 AM.
Old 10-28-2004, 05:05 AM   #2
Registered: Jun 2004
Posts: 51

Original Poster
Rep: Reputation: 15
Unhappy Re: C program problem on delete duplicated nodes in linked list !

sorry error post!!

Last edited by antony_csf; 10-28-2004 at 05:11 AM.
Old 10-28-2004, 10:42 AM   #3
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Out of memory? You're not allocating any in your code. What's the exact error you're getting?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
concepts a linked list program in c ssg14j Programming 4 08-19-2005 10:10 AM
linked list + c dilberim82 Programming 5 05-04-2005 11:48 PM
linked lists w/ nodes? |2ainman Programming 1 05-19-2004 01:32 AM
imple,menting a linked list in c program in linux bprasanth_20 Programming 17 10-25-2003 02:06 AM
C++ linked list fun chens_83 Programming 2 08-04-2003 07:40 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:56 PM.

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