GeekInterview.com
  I am new, Sign me up!
 
Home C
 

sizeof Operator

 
Category: C
Comments (0)


What is sizeof operator?


sizeof will return the number of bytes reserved for a variable or data type. The sizeof operator is a compile-time operator that returns an integer value. In other words since sizeof is a compile time operator, when used in a expression, it does not get compiled into executable code in the expression.


Syntax of this operator is


sizeof (type-name)


For instance if one wants to know the length of a data type it can be obtained by using sizeof operator as follows:


main()
{
printf("%d n", sizeof(int));
}


This returns the size of integer which is generally 2.


Suppose we have a program like below


main()
{
int a;
float b=4.0
a= sizeof(10) / sizeof(b);
)


Then the result would be sizeof integer value generally would be 2 and sizeof float which would be generally 4. Therefore result would be 2/4 which gives result as 0.



Read Next: typecasting in C



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape