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
Why clrscr is used in c?
find out largest elemant of diagonalmatrix
What is the advantage of using #define to declare a constant?
What is the heap?
How to establish connection with oracle database software from c language?
what is the difference between 123 and 0123 in c?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
What is enumerated data type in c?
What are the 4 types of functions?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
What are valid operations on pointers?
What is a macro in c preprocessor?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
What is header file in c?
What is wrong with this initialization?