Telegram Group & Telegram Channel
📚 Мини-справочник по основным типам данных C++

Делимся компактным справочником по основным типам данных в C++. Сохраняйте себе на будущее.

🔢 Целочисленные типы

int — 4 байта, от -2,147,483,648 до 2,147,483,647
short — 2 байта, от -32,768 до 32,767
long — 4 байта (Windows) или 8 байт (Unix)
long long — 8 байт, от -9,223,372,036,854,775,808 до 9,223,372,036,854,775,807

Модификаторы:
unsigned — только положительные числа, удваивает верхний предел
signed — со знаком (по умолчанию)


unsigned int counter = 100;
short temperature = -15;
long long population = 7800000000;


🔡 Символьные типы

char — 1 байт, обычные символы ASCII
wchar_t — 2 или 4 байта, широкие символы (Unicode)
char16_t — 2 байта, символы UTF-16 (C++11)
char32_t — 4 байта, символы UTF-32 (C++11)


char letter = 'A';
wchar_t unicodeChar = L'Ф';
char16_t utf16Char = u'Ж';


🔄 Числа с плавающей точкой

float — 4 байта, точность ~7 цифр, диапазон ±3.4e±38
double — 8 байт, точность ~15 цифр, диапазон ±1.7e±308
long double — 8-16 байт, точность ≥ double, диапазон зависит от компилятора


float price = 19.99f; // 'f' суффикс для float
double pi = 3.14159265359;
long double precise = 1.23456789123456789L; // 'L' суффикс


🧮 Логический тип

bool — 1 байт, значения: true или false


bool isActive = true;
bool hasPermission = false;


🗄 Производные типы

Массивы: int numbers[5];
Указатели: int* ptr;
Ссылки: int& ref = value;
Строки:
• C-строки: char str[] = "Hello";
• std::string: std::string text = "Hello";

🔄 Автоматическое определение типа (C++11)


auto x = 10; // int
auto y = 3.14; // double
auto z = "Hello"; // const char*


🧩 Тип Void

void — отсутствие типа (для функций без возвращаемого значения)
void* — указатель на данные любого типа

🔍 Как узнать размер типа




cout << "Размер int: " << sizeof(int) << " байт" << endl;


💡 Полезные советы

1. Используйте **size_t
для индексации и размеров
2. Для целых чисел с гарантированным размером используйте типы из <cstdint>: int32_t, uint64_t
3. Для денежных расчетов избегайте float из-за погрешностей округления

#cpp #programming

👉 @cpp_lib



tg-me.com/cpp_lib/1947
Create:
Last Update:

📚 Мини-справочник по основным типам данных C++

Делимся компактным справочником по основным типам данных в C++. Сохраняйте себе на будущее.

🔢 Целочисленные типы

int — 4 байта, от -2,147,483,648 до 2,147,483,647
short — 2 байта, от -32,768 до 32,767
long — 4 байта (Windows) или 8 байт (Unix)
long long — 8 байт, от -9,223,372,036,854,775,808 до 9,223,372,036,854,775,807

Модификаторы:
unsigned — только положительные числа, удваивает верхний предел
signed — со знаком (по умолчанию)


unsigned int counter = 100;
short temperature = -15;
long long population = 7800000000;


🔡 Символьные типы

char — 1 байт, обычные символы ASCII
wchar_t — 2 или 4 байта, широкие символы (Unicode)
char16_t — 2 байта, символы UTF-16 (C++11)
char32_t — 4 байта, символы UTF-32 (C++11)


char letter = 'A';
wchar_t unicodeChar = L'Ф';
char16_t utf16Char = u'Ж';


🔄 Числа с плавающей точкой

float — 4 байта, точность ~7 цифр, диапазон ±3.4e±38
double — 8 байт, точность ~15 цифр, диапазон ±1.7e±308
long double — 8-16 байт, точность ≥ double, диапазон зависит от компилятора


float price = 19.99f; // 'f' суффикс для float
double pi = 3.14159265359;
long double precise = 1.23456789123456789L; // 'L' суффикс


🧮 Логический тип

bool — 1 байт, значения: true или false


bool isActive = true;
bool hasPermission = false;


🗄 Производные типы

Массивы: int numbers[5];
Указатели: int* ptr;
Ссылки: int& ref = value;
Строки:
• C-строки: char str[] = "Hello";
• std::string: std::string text = "Hello";

🔄 Автоматическое определение типа (C++11)


auto x = 10; // int
auto y = 3.14; // double
auto z = "Hello"; // const char*


🧩 Тип Void

void — отсутствие типа (для функций без возвращаемого значения)
void* — указатель на данные любого типа

🔍 Как узнать размер типа




cout << "Размер int: " << sizeof(int) << " байт" << endl;


💡 Полезные советы

1. Используйте **size_t
для индексации и размеров
2. Для целых чисел с гарантированным размером используйте типы из <cstdint>: int32_t, uint64_t
3. Для денежных расчетов избегайте float из-за погрешностей округления

#cpp #programming

👉 @cpp_lib

BY Библиотека C/C++ разработчика


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/cpp_lib/1947

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

How To Find Channels On Telegram?

There are multiple ways you can search for Telegram channels. One of the methods is really logical and you should all know it by now. We’re talking about using Telegram’s native search option. Make sure to download Telegram from the official website or update it to the latest version, using this link. Once you’ve installed Telegram, you can simply open the app and use the search bar. Tap on the magnifier icon and search for a channel that might interest you (e.g. Marvel comics). Even though this is the easiest method for searching Telegram channels, it isn’t the best one. This method is limited because it shows you only a couple of results per search.

To pay the bills, Mr. Durov is issuing investors $1 billion to $1.5 billion of company debt, with the promise of discounted equity if the company eventually goes public, the people briefed on the plans said. He has also announced plans to start selling ads in public Telegram channels as soon as later this year, as well as offering other premium services for businesses and users.

telegram from tr


Telegram Библиотека C/C++ разработчика
FROM USA