Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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)....................

Answers were Sorted based on User's Feedback



let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

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

let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

Answer / sumanshu

55 BYTES OF MEMORY NEEDED.
ADDRESSS-IS BY DEFAULT

Is This Answer Correct ?    1 Yes 0 No

let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

Answer / vrushali

Memory allocated will be word aligned in nature.
e.g. for int the address would be allocated as a multiple of
4 .... Next char would start the n+1 where n = multiple of 4.

Similarly next....
when we do sizeof structure we get 60 bytes...
But originally , it should be
4 + 1+ 4+ 8 + 4 *10 = 57 bytes.
The extra three bytes are from char where 3 bytes are wasted
in memory space.

Is This Answer Correct ?    2 Yes 2 No

let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

Answer / vignesh1988i

please be clear ...............i could not understand ur
reply fully.... please brief it .......sorry

Is This Answer Correct ?    0 Yes 0 No

let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

Answer / vrushali

Sorry .. i did not get your context....

Is This Answer Correct ?    1 Yes 1 No

let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

Answer / vignesh1988i

see from the above code i want wat address will get stored in the structure pointer temp??????????????

Is This Answer Correct ?    0 Yes 0 No

let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

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

let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; ..

Answer / aman

your question is wrong it will give an error because u r declaring the variable 2 times and if u name it something else then the memory size will be 35 bytes on 32 bit compiler

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

0 Answers   XYZ,


can we initialize all the members of union?

2 Answers  


How many types of arrays are there in c?

0 Answers  


Explain the difference between #include "..." And #include <...> In c?

0 Answers  


how to find sum of digits in C?

21 Answers   CTS, Infosys,


What is the restrict keyword in C?

2 Answers  


int main() { int days; printf("enter days you are late"); scanf("%d",days); if (days<=5) printf("5o paisa fine"); if (days<=10&&days>=6) printf("1rs fine"); if(days>10) printf("10 rs fine"); if(days=30) printf("membership cancelled"); return 0; } tell me whats wrong in this program? is it right?

2 Answers  


main() { int arr[5]={23,67}; printf("%d%d%d",arr[2],arr[3],arr[4]); }

9 Answers   TCS,


main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

4 Answers  


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

0 Answers  


what different between c and c++

1 Answers  


what is the use of keyword volatile??

4 Answers   LG Soft,


Categories