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 |
to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD output should of SAD
main() { int i=400,j=300; printf("%d..%d"); }
All the combinations of prime numbers whose sum gives 32
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
main() { char not; not=!2; printf("%d",not); }
WAP to display 1,2,3,4,5........N
main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(“%d ” ,*p); p++; } }
main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }
create a C-code that will display the total fare of a passenger of a taxi if the driver press enter,the timer will stop. Every 10 counts is 2 pesos. Initial value is 25.00
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)