• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: linked list problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: linked list problem


  • Subject: Re: linked list problem
  • From: Andrew Farmer <email@hidden>
  • Date: Mon, 31 Mar 2008 15:19:26 -0700

On 31 Mar 08, at 14:39, stephen joseph butler wrote:
On Mon, Mar 31, 2008 at 4:31 PM, Nick Rogers <email@hidden> wrote:
In my code:

DIR *temp = parentDir; //parentDir is allocated initially but its
next is not allocated at this point
while (temp)
{
temp = (DIR*)temp->next; //here next is null so, temp now is
null
}
temp = newDir; //here newDir is already allocated, but temp
doesn't
get allocated, in a way parentDir->next remains null.



While this type of code works fine on VS2005, it doesn't wprk here in cocoa. How else can I reach the end of the list and add a new node?


There is no way the code you show works for any C compiler, let alone
VS2005. You never do the linking part of the linked list.

In particular, the (effective) code sequence

	A = B;
	B = C;

does not set A to C in any language I'm familiar with.

Also, I'd recommend against naming any type DIR, as there's a libc type by that name in <dirent.h>.
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: linked list problem
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >linked list problem (From: Nick Rogers <email@hidden>)
 >Re: linked list problem (From: "stephen joseph butler" <email@hidden>)

  • Prev by Date: Cocoa GUI app invocation from CLI with arguments
  • Next by Date: Re: Simple menu-action question
  • Previous by thread: Re: linked list problem
  • Next by thread: Re: linked list problem
  • Index(es):
    • Date
    • Thread