I have watched videos by different people on youtube and now i am little bit confused
first two[(1) (2)] are of same type without typedef and then two[(3) (4)] are of same type with typedef but the way of writing them is different
Please mention if any of the below represented structure is wrong and why with number. I am assigning number to all of the these formats
(1)
struct tag{
int number;
char *name;
float num;
};
main()
{
struct tag name;
name firstmember;
------code-------
return 0;
}
Next type i have seen is same as the above but :
(2)
struct tag{
int number;
char *name;
float num;
}name;
main()
{
name firstmember;
------code-------
return 0;
}
Next is using structure with typedef:
(3)
typedef struct tag{
int number;
char *name;
float num;
}name;
main()
{
name firstmember;
------code-------
return 0;
}
same version of typedef with other one:
(4)
struct tag{
int number;
char *name;
float num;
};
main()
{
typedef struct tag name;
name firstmember;
------code-------
return 0;
}
Please mention if any of the the above represented examples have any kind of error
Lastly this doubt is completely different from the above examples
if we don't put a structure tag just after the word struct and do like this
(5)
struct {
int number;
char *name;
float num;
}tag;
main(){}
does this word 'tag' remains structure tag or if its after '}' so its a structure name now ? What is it? If it becomes the name why do we use the structure tags anyways?
Please respond to this question after reading all my doubts carefully in well written format