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

When should you use a type cast?

593


What is a pointer variable in c language?

645


why do some people write if(0 == x) instead of if(x == 0)?

655


How is pointer initialized in c?

587


Explain how can a program be made to print the name of a source file where an error occurs?

691






What are types of structure?

605


What is the use of header?

624


Why is a semicolon (;) put at the end of every program statement?

628


What are identifiers c?

566


What is a volatile keyword in c?

638


What is realloc in c?

581


Explain what is a program flowchart and explain how does it help in writing a program?

650


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

589


Write a program to print all permutations of a given string.

644


What is gets() function?

673