Find Error if any in below code, Justify ur answer:

struct xx
{
int a;
struct yy
{
char c;
struct xx* p;
}
struct yy* q;
}

Answer Posted / vignesh1988i

here the error is the variable declaration of struct xx is not permitted inside struct yy. since this is nested structures ,so according to the braces for each structures the variables for that particular structure should be assigned (OR)
if this is written as code given below this will be correct.
THIS IS THE CORRECT CODE WHICH WILL GIVE NO ERROR.
struct xx
{
int a;
}
struct yy
{
char c;
struct xx *p;
}
struct yy *q

THE SAME CODE GIVEN IN THE QUESTION CAN BE CORRECTED AS :

struct xx
{
int a;
struct yy
{
char c;
}*q // for struct yy
}*p // for struct xx


thank u

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What the different types of arrays in c?

794


What is structure pointer in c?

774


Explain data types & how many data types supported by c?

802


Explain why can’t constant values be used to define an array’s initial size?

1081


What is the role of && operator in a program code?

787


What is the function of this pointer?

871


Explain the properties of union. What is the size of a union variable

916


Explain what are compound statements?

797


What is the scope of local variable in c?

768


Should a function contain a return statement if it does not return a value?

806


What are the 4 data types?

755


How can I change the size of the dynamically allocated array?

875


How can I use a preprocessorif expression to ?

774


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

976


difference between object file and executable file

6317