C Programming - Typedef - Discussion

Discussion Forum : Typedef - Find Output of Program (Q.No. 5)
5.
What will be the output of the program?
#include<stdio.h>

typedef struct error {int warning, err, exception;} ERROR;
int main()
{
    ERROR e;
    e.err=1;
    printf("%d\n", e.err);
    return 0;
}
0
1
2
Error
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
14 comments Page 2 of 2.

Nagaraj said:   1 decade ago
Hey in the structure, how can we declare like that ?

Every variablemust be declared separately, am I right?

Sathya said:   1 decade ago
In c how can u create an object like ERROR e; ? Is it correct?

Instead of using e.err , why cant we simply use ERROR.err?

Saravanan.C said:   1 decade ago
typedef struct error
{
int warning;
int err;
int exception;
}ERROR;

This is how this normally looks....

Here a structure named error is typedefed as ERROR(means in place of struct error it can be said as ERROR)...
then e is a structure..
e.err is accessing a member in the structure... thats it.... is it correct......?

Varad said:   1 decade ago
any one help me for this problem plzz...


Post your comments here:

Your comments will be displayed after verification.