Discussion
Assume that size of an integer is 32 bit. What is the output of following program?
#include <stdio.h>
struct st
{
int x;
static int y;
};
int main()
{
printf("%d", sizeof(struct st));
return 0;
}
Answer: C
Correct answer: Compiler Error
There is no static member in C - that is a C++ feature. A structure in C is a layout of data, with no storage shared across instances, so the declaration is rejected. (In C++ it would compile, and sizeof would be 4, since a static member is not part of each object.)
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development