C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Point Out Correct Statements (Q.No. 4)
4.
Which of the structure is incorrcet?
1 :
struct aa
{
    int a;
    float b;
};
2 :
struct aa
{
    int a;
    float b;
    struct aa var;
};
3 :
struct aa
{
    int a;
    float b;
    struct aa *var;
};
1
2
3
1, 2, 3
Answer: Option
Explanation:

Option B gives "Undefined structure in 'aa'" error.

Discussion:
29 comments Page 2 of 3.

Suraj said:   7 years ago
B. is incorrect because there is no declaration of struct aa;

But in c there is pointer *aa so it can declare it self as a garbage value.
(1)

Seema said:   1 decade ago
*var is the pointer variable of structure & var is variable of structre which cannot be created before creation of structre.

Vinod kumar said:   1 decade ago
In this prob. We couldn't create a same structure type within that structure. It will make linking error.

Arulrexin said:   1 decade ago
If we can see that program is that second time used stuct variable with using pointer.

Sakthi said:   7 years ago
Shall I declare struct aa var; outside the structure? Can Anyone explain, please?

Bhanu prataap said:   9 years ago
I can't understand please give me the deep description why the answer is B?

Sandeep Reddy said:   8 years ago
Because pointer and structure are same data types (user defined).

Md kamal said:   8 years ago
I am not understanding this. Please, anyone explain this.

Kirti said:   1 decade ago
Why B is wrong and C is correct? Please explain.

Rashmi said:   1 decade ago
Why B is wrong and C is correct? Please explain.


Post your comments here:

Your comments will be displayed after verification.