C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - Point Out Errors (Q.No. 2)
2.
Point out the error in the program?
typedef struct data mystruct;
struct data
{
    int x;
    mystruct *b;
};
Error: in structure declaration
Linker Error
No Error
None of above
Answer: Option
Explanation:
Here the type name mystruct is known at the point of declaring the structure, as it is already defined.
Discussion:
17 comments Page 1 of 2.

Mayank said:   1 decade ago
Can any one explain this?

Satyaprakash said:   1 decade ago
Can anyone explain? why do you use typedef?

Gowthami said:   1 decade ago
Hello please explain the line "typedef struct data mystruct;".

Amit kumar said:   1 decade ago
The typedef a simply definition of struct types which can be used for short name of structure definition.

Deepa.k.m said:   1 decade ago
Please tell the reason.

Shweta said:   1 decade ago
Why we use typedef and what is it's meaning?

Coders said:   1 decade ago
typedef struct data mystruct;

Means we are making mystruct a member of struct at the time of declaration.

Krishna said:   1 decade ago
Please explain the typedef?

Swathi said:   1 decade ago
typedef is used to give alternative name for any of the data type.

In this example "typedef struct data mystruct" indicates that mystruct is same as type struct data.

Hence mystruct *b means b is a pointer of the type struct data.

Janani said:   1 decade ago
What is the use of using this typedef?


Post your comments here:

Your comments will be displayed after verification.