C++ Tutorial/Language Basics/Variable size — различия между версиями


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
(нет различий)

Текущая версия на 10:30, 25 мая 2010

Variable size: int, short, long, char, float and double

#include <iostream>
 
 int main()
 {
     std::cout << "The size of an int is:\t\t";
     std::cout << sizeof(int) << " bytes.\n";
     std::cout << "The size of a short int is:\t"; 
     std::cout << sizeof(short) << " bytes.\n";
     std::cout << "The size of a long int is:\t";
     std::cout << sizeof(long) << " bytes.\n";
     std::cout << "The size of a char is:\t\t";
     std::cout << sizeof(char) << " bytes.\n";
     std::cout << "The size of a float is:\t\t";
     std::cout << sizeof(float) << " bytes.\n";
     std::cout << "The size of a double is:\t";
     std::cout << sizeof(double) << " bytes.\n";
 
     return 0;
 }
The size of an int is:          4 bytes.
The size of a short int is:     2 bytes.
The size of a long int is:      4 bytes.
The size of a char is:          1 bytes.
The size of a float is:         4 bytes.
The size of a double is:        8 bytes.