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

What do you mean by a sequential access file?

835


What is the use of a ‘’ character?

826


Write a simple code fragment that will check if a number is positive or negative.

926


What is 2c dna?

842


What does nil mean in c?

932


Can a pointer be volatile in c?

740


In a switch statement, explain what will happen if a break statement is omitted?

848


What is data structure in c language?

856


c language interview questions & answer

1717


Should I learn c before c++?

995


What is #include in c?

812


what is the different bitween abap and abap-hr?

1952


What does return 1 means in c?

833


How can I implement a delay, or time a users response, with sub-second resolution?

858


What is c mainly used for?

838