Is the following code legal?

struct a

{

int x;

struct a *b;

}

Answers were Sorted based on User's Feedback



Is the following code legal? struct a { int x; struct..

Answer / susie

Answer :

Yes.

Explanation:

*b is a pointer to type struct a and so is legal. The
compiler knows, the size of the pointer to a structure even
before the size of the structure

is determined(as you know the pointer to any type is of same
size). This type of structures is known as
‘self-referencing’ structure.

Is This Answer Correct ?    2 Yes 0 No

Is the following code legal? struct a { int x; struct..

Answer / pavan_mustyala

The code snippet is absolutely valid and this concept which
is comes under "self- referential" concept is used to
develop linked lists.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

0 Answers  


main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }

1 Answers  


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”

5 Answers   HCL,


could you please send the program code for multiplying sparse matrix in c????

0 Answers  






#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }

2 Answers  


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


how can u draw a rectangle in C

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


How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!

1 Answers  


#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }

0 Answers  


main() { static int var = 5; printf("%d ",var--); if(var) main(); }

1 Answers  


How to read a directory in a C program?

4 Answers  


Categories