6 Replies - 1057 Views - Last Post: 20 February 2013 - 12:55 PM Rate Topic: -----

#1 johngoodman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 05-February 13

Linked List - inserting node

Posted 18 February 2013 - 10:18 PM

I'm trying to create a function that allows insertion anywhere in a linked list...here is what I have so far but it isn't quite working

void llAddAtIndex(LinkedList** ll, char* value, int index) {

  LinkedList* newNode;
 // newNode = (LinkedList*)malloc(sizeof(*newNode));
  newNode = *ll;
  
  if(index == 0){
	newNode->next = newNode;
	newNode = newNode;
	} else {
	LinkedList* n = newNode;
		for(int i = 0; i < index; i++){
			n = n->next;
		}
		newNode->next = n->next;
		n->next = newNode;
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Linked List - inserting node

#2 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: Linked List - inserting node

Posted 18 February 2013 - 10:21 PM

View Postjohngoodman, on 19 February 2013 - 10:48 AM, said:

I'm trying to create a function that allows insertion anywhere in a linked list...here is what I have so far but it isn't quite working


Well, what do you mean by it isn't quite working. Is it throwing any errors, or inserting garbage values...please be more specific.

And yes, please avoid creating duplicate posts for the same topic.

regards,
Raghav

This post has been edited by raghav.naganathan: 18 February 2013 - 10:24 PM

Was This Post Helpful? 0
  • +
  • -

#3 jimblumberg  Icon User is online

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: Linked List - inserting node

Posted 18 February 2013 - 10:25 PM

Also avoid cross posting to different forums.

What is wrong with the advice you were given in that forum?

Jim
Was This Post Helpful? 2
  • +
  • -

#4 Switters  Icon User is offline

  • D.I.C Head

Reputation: 25
  • View blog
  • Posts: 110
  • Joined: 03-June 12

Re: Linked List - inserting node

Posted 20 February 2013 - 12:30 PM

View Postjimblumberg, on 18 February 2013 - 10:25 PM, said:

Also avoid cross posting to different forums.

What is wrong with the advice you were given in that forum?

Jim



Isn't it a bit of an overreach to be policing his behavior on another forum? I mean, there are things he could've done differently sure, but he's getting flack because he's unlucky enough to have the other forum that he posts to read by someone on THIS forum? Seems a little Orwellian...
Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg  Icon User is online

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: Linked List - inserting node

Posted 20 February 2013 - 12:39 PM

Quote

Isn't it a bit of an overreach to be policing his behavior on another forum?

In my opinion, no! Posting all over the Internet is very rude, again in my opinion.

I made no effort of "policing", just informing other people of this issue, so they can be aware of the answers already given so they don't repeat what has already been said, or whatever. I didn't make any effort to prevent anyone who wished to answer from doing so if they so wished.

There is absolutely nothing stopping you or anyone else from trying to answer the question.

Jim

This post has been edited by jimblumberg: 20 February 2013 - 12:41 PM

Was This Post Helpful? 0
  • +
  • -

#6 Switters  Icon User is offline

  • D.I.C Head

Reputation: 25
  • View blog
  • Posts: 110
  • Joined: 03-June 12

Re: Linked List - inserting node

Posted 20 February 2013 - 12:46 PM

View Postjimblumberg, on 20 February 2013 - 12:39 PM, said:

Quote

Isn't it a bit of an overreach to be policing his behavior on another forum?

In my opinion, no! Posting all over the Internet is very rude, again in my opinion.

I made no effort of "policing", just informing other people of this issue, so they can be aware of the answers already given so they don't repeat what has already been said, or whatever. I didn't make any effort to prevent anyone who wished to answer from doing so if they so wished.

While I don't wish to answer this question, there is absolutely nothing stopping you from trying to answer the question.

Jim


Meh, fair enough, I don't mean to pick a fight with you. Sometimes the help one needs is not forthcoming and posting to a different forum might have better results. I don't find it rude to post a question elsewhere. You find it rude because you're in a very small subset of people who actually read this forum and that one...so your post amounts to "I could answer this question but here is why I choose not to." Anyway, as I said, I'm not trying to pick a fight with you, you've certainly answered a question or 2 of mine in the past. Your reaction just struck me as a bit much.
Was This Post Helpful? 0
  • +
  • -

#7 jimblumberg  Icon User is online

  • member icon


Reputation: 4142
  • View blog
  • Posts: 12,892
  • Joined: 25-December 09

Re: Linked List - inserting node

Posted 20 February 2013 - 12:55 PM

Quote

Sometimes the help one needs is not forthcoming and posting to a different forum might have better results.

If the OP would have waited for an answer this may be true. But this post was posted within minutes of the original post in the other forum. This is where the rudeness shines through. If he would have waited a few hours and not gotten any answers then finding a new forum might have been acceptable. However he was getting answers in that other forum, but didn't seem to be paying any attention to the answers given, again bad form. But as I said, if you wish to try to answer the question, have at it, no one is stopping you.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1