Re: Link lists..



johnnash wrote:
i'm declaring a data structure for link list of integers in A.h

#ifndef A_H (can anyone please explain how ifndef works as well..i
just seem to see it in almost every program)

Doesn't your text book or tutorial explain this?

If they don't help, simply Googling for "ifndef" gave me loads of
hits...

The pattern

#ifndef something
#define something
....
....
#endif

is a common technique for handling multiple inclusions of headers.

[snip]

node * head; /*definition, is this sufficient for link list ?, can i
initialize head to NULL here itself */

LL()/* computes the link list */
{

node *p, *prev; /*prev is previous node */

head = NULL;

head->next = NULL;

Bang! you've just tried to dereference a NULL Pointer...

[snip]

What was your actual question?
.



Relevant Pages