// This is an example linked list
typedef struct NODE_TYP
{
int id;
int some_number;
char some_text[32];
NODE_TYP *next; // Line 21
} NODE;
errors are:
D:\Projects\Tilt Table\GSprite.H(21) : error C2061: syntax error : identifier ''NODE_TYP''
D:\Projects\Tilt Table\GSprite.H(22) : error C2059: syntax error : ''}''
So how would i do it in C?
thanks
-----------------------------
-cow_in_the_well
http://cowswell.gda.ods.org/
- Don't Panic -
Linked Lists in C
This compiles fine in CPP but compiled under C it comes up with annyoing errors.
- Thomas Cowellwebsite | journal | engine video
Since the struct isn''t fully typedef''d yet, you can''t just use "NODE_TYP" to define the pointer on line 21. You need to use the "struct" keywork. In other words...
struct NODE_TYP *next;
That should work, in cpp the typedef doesn''t matter the namespace for NODE_TYP is automatically "typedef"''d, while in regular C it isn''t.
-Omalacon
struct NODE_TYP *next;
That should work, in cpp the typedef doesn''t matter the namespace for NODE_TYP is automatically "typedef"''d, while in regular C it isn''t.
-Omalacon
okay, but when i do this i cannot set next to NULL.
D:\Projects\Tilt Table\GSprite.c(25) : error C2115: ''='' : incompatible types
thanks
-----------------------------
-cow_in_the_well
http://cowswell.gda.ods.org/
- Don't Panic -
foo->next = NULL;
D:\Projects\Tilt Table\GSprite.c(25) : error C2115: ''='' : incompatible types
thanks
-----------------------------
-cow_in_the_well
http://cowswell.gda.ods.org/
- Don't Panic -
- Thomas Cowellwebsite | journal | engine video
It''s not safe, but you can use ''void *'' to store pointer
to next element. Then you must cast this pointer to ''NODE *''.
DLife
to next element. Then you must cast this pointer to ''NODE *''.
DLife
Its working now- Don''t Panic!
-----------------------------
-cow_in_the_well
http://cowswell.gda.ods.org/
- Don't Panic -
-----------------------------
-cow_in_the_well
http://cowswell.gda.ods.org/
- Don't Panic -
- Thomas Cowellwebsite | journal | engine video
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement