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
When should you use a type cast?
What is a pointer variable in c language?
why do some people write if(0 == x) instead of if(x == 0)?
How is pointer initialized in c?
Explain how can a program be made to print the name of a source file where an error occurs?
What are types of structure?
What is the use of header?
Why is a semicolon (;) put at the end of every program statement?
What are identifiers c?
What is a volatile keyword in c?
What is realloc in c?
Explain what is a program flowchart and explain how does it help in writing a program?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
Write a program to print all permutations of a given string.
What is gets() function?