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


Please Help Members By Posting Answers For Below Questions

What is the meaning of typedef struct in c?

600


Write a simple code fragment that will check if a number is positive or negative.

711


What is I ++ in c programming?

630


if p is a string contained in a string?

1406


I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.

1500






What is data structure in c language?

610


What are conditional operators in C?

630


Where we use clrscr in c?

710


What is equivalent to ++i+++j?

648


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

815


State two uses of pointers in C?

642


Write a program to identify if a given binary tree is balanced or not.

689


How to establish connection with oracle database software from c language?

1679


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1320


What is a function in c?

577