let's take a code

struct FAQ
{
int a;
char b;
float c;
double d;
int a[10];
}*temp;

now explain me how the memory will be allocated for the
structure FAQ and what address will be in the structure
pointer (temp)....................

Answer Posted / sharan

when u declare a structure there is no memory allocated yet.
memory will be allocated after creating an
instance(variable).Here, there is an instance (pointer
variable pointing to structure FAQ ). But the compiler
allocated only 4 bytes of memory for the variable temp. But
the this temp contains garbage address or 0 if it is
global. to allocated memory of size 60 byte u need to use
malloc function.

Ex: temp = malloc ( sizeof ( struct FAQ ) );

now 60 bytes of memory has been allocated from the heap. and
the starting address of this memory chunk is stored in
variable temp.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is r written in c?

722


What is nested structure in c?

608


What is null pointer constant?

592


What is the purpose of main( ) in c language?

615


How do I read the arrow keys? What about function keys?

610






Can a program have two main functions?

567


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

4490


Write a program to find the biggest number of three numbers in c?

588


write a program to concatenation the string using switch case?

1556


What do you mean by invalid pointer arithmetic?

637


How can I get random integers in a certain range?

609


Can I initialize unions?

590


Explain the properties of union.

607


What is the difference between if else and switchstatement

1310


What is property type c?

599