C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - True / False Questions (Q.No. 11)
11.
On declaring a structure 0 bytes are reserved in memory.
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
20 comments Page 1 of 2.

Avishek said:   1 decade ago
When a structure is declared no memory space is allocated till a variable is declared.

Then how can the answer be false ?

Harshith M L said:   1 decade ago
Yep only after a variable is declared memory will be allocated till then no memory will be allocated.

Amit pawar. said:   1 decade ago
the memory will be allocated only after structure variables are declared.
then how the answer is false.

Sachin kakatkar said:   1 decade ago
sorry The memory is allocated when structure is declared .the memory not allocated when structure is defined. so answer is correct.

Umesha krishnegowda said:   1 decade ago
NO, answer is not correct. Because after structure variable is declared then only memory will allocated.

Nikhil said:   1 decade ago
If mem is allocated when struct is declare can you tell me how many bytes declare at that time.

Subhra said:   1 decade ago
Answer is not correct ,because at the time of declaring the structure no memory space is allocated, but when we define it,then the memory is allocated...example

case 1:
struct student
{
int roll;
};//memory allocation not done
void main()
{
printf("hello");
}
case 2:
struct student
{
int roll;
};//memory allocation still not done
void main()
{
struct stdent s1;//now the allocation is done

printf("hello");
}

Ingale Yogesh said:   1 decade ago
Memory is allocated only when an instance of structure is created, till no memory is allocated.

Naresh said:   1 decade ago
Here Structure reserved one bytes when it declare without any member declare inside it.

A v said:   1 decade ago
#include<stdio.h>
#include<string.h>

int main()
{
typedef struct
{
int a;
int m;

} stu;
printf("%d",sizeof(stu ));
return 0;
}

This gives 8 in code block, that means memory is allocated at time of decleration


Post your comments here:

Your comments will be displayed after verification.