Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Intermediate
Jun 4, 2001



Application Security Testing: An Integral Part of DevOps

Calculate the Sizes of Data Types at Runtime

The size of the int, char, long, or short depends on what operating system and compiler version you are using. The same applies for short and long data types.

The usual method of determining size is to use the sizeof() function to find the number of bytes each data type occupies. But sizeof() is done at compile time, not at runtime.

The following code fragment calculates the number of bits in each of the above data types at runtime (repeat by changing i to long, short, char, etc.):
  int i = 1;
  int count = 0;
  while (i<<1)

  cout << 
Rajesh Chathapuram
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date