typedef struct error{int warning, error, exception;}error;

main()

{

error g1;

g1.error =1;

printf("%d",g1.error);

}



typedef struct error{int warning, error, exception;}error; main() { ..

Answer / susie

Answer :

1

Explanation

The three usages of name errors can be distinguishable
by the compiler at any instance, so valid (they are in
different namespaces).

Typedef struct error{int warning, error, exception;}error;

This error can be used only by preceding the error by struct
kayword as in:

struct error someError;

typedef struct error{int warning, error, exception;}error;

This can be used only after . (dot) or -> (arrow) operator
preceded by the variable name as in :

g1.error =1;

printf("%d",g1.error);

typedef struct error{int warning, error, exception;}error;

This can be used to define variables without using the
preceding struct keyword as in:

error g1;

Since the compiler can perfectly distinguish between these
three usages, it is perfectly legal and valid.

Note

This code is given here to just explain the concept
behind. In real programming don’t use such overloading of
names. It reduces the readability of the code. Possible
doesn’t mean that we should use it!

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { int i = 3; for (;i++=0;) printf(“%d”,i); }

1 Answers   CSC,


how can u draw a rectangle in C

53 Answers   Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above

2 Answers   HCL,


/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }

4 Answers  






What is the hidden bug with the following statement? assert(val++ != 0);

1 Answers  


why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


How we print the table of 2 using for loop in c programing?

14 Answers   HCL, Wipro,


WAP to display 1,2,3,4,5........N

2 Answers  


write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }

3 Answers  


write a c program to Create a mail account by taking the username, password, confirm password, secret_question, secret_answer and phone number. Allow users to register, login and reset password(based on secret question). Display the user accounts and their details .

2 Answers  


Categories