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 are the types of unary operators?
What is the purpose of main( ) in c language?
What is bubble sort in c?
What does %p mean?
What are the storage classes in C?
shorting algorithmS
How many data structures are there in c?
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
What is the use of header files?
What is typedef example?
Why isnt there a numbered, multi-level break statement to break out
What is scope of variable in c?
Not all reserved words are written in lowercase. TRUE or FALSE?
What is wrong with this program statement? void = 10;
What is the meaning of 2d in c?