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 / reachhary

As already told by vrushali memory to a structure is always
allocated along word boundaries. So int would fetch 4 bytes
(assumed that the int in ur machine takes 4 and word is 4
bytes). Similarly char would take 1 but since the next entry
i.e. float requires 4 so char would be given 4 (3 extra )
and so on for the remaining summing upto 60 as already
indicated.

By default temp would have the base address of the structure
i.e. pointing to the first integer i.e. 'a' in our case.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stream water?

658


What does void main return?

606


Why string is used in c?

581


What is line in c preprocessor?

616


What is wrong in this statement?

606






Explain how can a program be made to print the line number where an error occurs?

694


What are the c keywords?

750


What standard functions are available to manipulate strings?

562


How many types of arrays are there in c?

595


given post order,in order construct the corresponding binary tree

2323


Explain what is gets() function?

633


Explain what is the concatenation operator?

628


What is the need of structure in c?

566


How can a program be made to print the name of a source file where an error occurs?

731


What is data types?

641