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
What the different types of arrays in c?
What is structure pointer in c?
Explain data types & how many data types supported by c?
Explain why can’t constant values be used to define an array’s initial size?
What is the role of && operator in a program code?
What is the function of this pointer?
Explain the properties of union. What is the size of a union variable
Explain what are compound statements?
What is the scope of local variable in c?
Should a function contain a return statement if it does not return a value?
What are the 4 data types?
How can I change the size of the dynamically allocated array?
How can I use a preprocessorif expression to ?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
difference between object file and executable file