## Recommended Posts

Ainokea    435
I am reading a tutorial on md2 loading and all the structores for the md2 look like this:
typedef struct MD2_TEXTCOORD_TYP
{
short u,v;
}MD2_TEXTCOORD, *MD2_TEXTCOORD_PTR;


and the tutorials also says that the data types must be identical to this. However I was wondering if I could do it like this:
struct MD2_TEXTCOORD
{
short u,v;   //texture coodinate
};


and when I need a pointer I just declare that type as a pointer. I.E instead of this: foo(MD2_TEXTCOORD_PTR); I could do this: foo(MD2_TEXTCOORD *md2);

##### Share on other sites
nts    968

that should be fine, they are equivalent

##### Share on other sites
Ainokea    435
Quote:
 Original post by ntsthat should be fine, they are equivalent

thanks. rating up up for you.

##### Share on other sites
nts    968
Quote:
Original post by Ainokea
Quote:
 Original post by ntsthat should be fine, they are equivalent

thanks. rating up up for you.

Wow all it took was 7 words, :D

Thanks, now i hope i wasn't horribly wrong somehow :D

##### Share on other sites
their equivalent assuming your programming in c++. if your in c, the typedef helps you. You see, when you declare a struct in c, it looks like this

//DEFINITION
struct MyStruct
{
int Content1;
int Content2;
};

int main()
{
struct MyStruct WhateverImGonnaCallThisVar; //the actual DECLARATION

WhateverImGonnaCallThisVar.Content1 = 0;

return 0;
}

******************************

with c++, the struct is optional, however, the typedef version, eliminates the need for the struct in the declaration (in both c and c++) but if your programming in c++, dont do the typedef

EDIT: to clarify, no matter what you do (in c or c++), you need the struct keyword before the definition of the class

hope that helps
-Dan

##### Share on other sites
Ainokea    435
My only problem was knowing if I had to use the same name or not. Thanks any ways and rating up for you.