Is the following code legal?
struct a
{
int x;
struct a *b;
}
Answers were Sorted based on User's Feedback
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 |
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 |
how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns
main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”
could you please send the program code for multiplying sparse matrix in c????
#define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); }
how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!
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!
#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(); }
main() { static int var = 5; printf("%d ",var--); if(var) main(); }
How to read a directory in a C program?