gyantonic
Login
Create Account
Home
Placement Preparation
Freshers Jobs
Questions
Career Discussions
Articles
Become Mentor
Students ! Create a Professional Resume in Minutes for FREE.
Answer the Question
How to calculate size of any structure without using "sizeof" operator?
By :
techie rich
On :
06-Dec-2012
Answers :
3
Report Abuse
Answer this Question
Existing Users - Login
*
Email Id :
*
Password :
Forgot Password
New Users - Create your Account
*
Email Id :
*
Password :
*
Confirm Password :
*
Full Name :
Share
|
Your Answer
Give your answer
Cancel
Previous Answers
struct point {
char x;
int i;
float f;
char is;
}pt;
int main()
{
// struct point pt = {0},
struct point *ppt;
*ppt = &pt;
unsigned char *p1 = 0, *p2 = 0;
size_t size = 0;
p1 = (unsigned char*)(ppt);
p2 = (unsigned char*)(++ppt);
size = p2 - p1; // size is now 8 bytes (2 longs)
printf("%d\n",size);
// same as sizeof(struct point) or sizeof(pt)
return 0;
}
On :
10-Jan-2013
Accept Count :
0
By :
yadav komal
Report Abuse
|
Accept Answer
|
Add Comment
sizeof(struct);
On :
25-Dec-2012
Accept Count :
0
By :
sravani uppalapati
Report Abuse
|
Accept Answer
|
Add Comment
struct point {
char x;
int i;
float f;
char is;
}pt;
int main()
{
// struct point pt = {0},
struct point *ppt;
*ppt = &pt;
unsigned char *p1 = 0, *p2 = 0;
size_t size = 0;
p1 = (unsigned char*)(ppt);
p2 = (unsigned char*)(++ppt);
size = p2 - p1; // size is now 8 bytes (2 longs)
printf("%d\n",size);
// same as sizeof(struct point) or sizeof(pt)
return 0;
}
On :
10-Dec-2012
Accept Count :
0
By :
ehete
Report Abuse
|
Accept Answer
|
Add Comment
Add a Question
Latest Answers
YOU HAVE 9 DOTS AND U HAVE TO JOIN THEM WITH FOUR LINES ,REMEMBER THAT THE LINES SHOU.....
A boat's speed with the current is 20 km/hr and the speed of the current is 5 km/hr. .....
Generally asked question In SSC On pipes and cistern Concept : Pipe A can fill in.....
Hi I am sharing Aptitude question which are generally asked in the interview : If 2x.....
What are manipulators?
Two boats are sailing in the sea on the two sides of a lighthouse. The angle of eleva.....
A right triangle with sides 3cm (base),4cm (perpendicular) is rotated the side of 3 c.....