typedef PtrToNode List; program defined List implementation

error C2146: syntax error : missing ';' before identifier 'List'

typedef struct Node *PtrNode;
typedef PtrToNode List; //my error is in this part
typedef PtrToNode Position;

struct Node
{
     ElementType Element;
     Position Next;
};

//function declarations
List MakeEmpty(List L);
int IsEmpty(List L);
int IsLast(Position P, List L);
Position Find( ElementType X, List L);
void Delete(ElementType X, List L);
Position FindPrevious(ElementType X, List L);
void Insert(ElementType X, List L, Position P);
void DeleteList(List L);
Position Header(List L);
Position First(List L);
Position Advance(Position P);
ElementType Retrieve(Position P);
crazyMonkeyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
>> typedef struct Node *PtrNode;

You cannot type-define a structure like this. Please remove the '*' before PtrNode.

I think what you want to do might be achieved by this:

typedef struct Node
{
    ElementType Element ;
    Node * Next ;
} List ;

Or:

struct Node
{
    ElementType Element ;
    Position * Next ;
} ;

typedef Node List ;

Also that: you need to define struct Node first before specifying a type-defined name for it.

Mayank.
0
 
efnCommented:
The compiler doesn't know what PtrToNode is.

I think you want the first typedef to define "PtrToNode", not "PtrNode".
0
 
tinchosCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: mayankeagle

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 
efnCommented:
With all due respect, I think my answer was better.

From the information available, crazyMonkey's problem was just defining PtrNode and then trying to refer to it with the different name PtrToNode.

With that correction, the design is OK and does not need the changes mayankeagle suggested.

--efn
0
 
tinchosCommented:
Sorry efn, I know your comment is correct,
but I felt that with your comment crazyMonkey would not have been able to solve his problem.
I think mayankeagle's comment summaryses all the modifications needed.

Anyway, its just my opinion and my recommendation is not final as the moderator will check it out before closing it.
0
All Courses

From novice to tech pro — start learning today.