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
What is operator promotion?
Why do we need volatile in c?
what is stack , heap ,code segment,and data segment
Why static variable is used in c?
Explain about the functions strcat() and strcmp()?
Can we declare variable anywhere in c?
Explain threaded binary trees?
What is equivalent to ++i+++j?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What is string function c?
what are the facialities provided by you after the selection of the student.
What is the use of clrscr?
Can stdout be forced to print somewhere other than the screen?
Why c is procedure oriented?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters