Questions about types

Pages: 12
However when I want to display the size of a Char, the output gives me something like Ç ⌂ and I don't understand why. Do you have an idea?
Last edited on
Geckoo wrote:
All is related at this Microsoft main page (and the next one) :
https://docs.microsoft.com/en-us/cpp/cpp/data-type-ranges?view=msvc-170
https://en.cppreference.com/w/cpp/language/types

Note that the Microsoft page contains Microsoft/Windows specific information.

Geckoo wrote:
when I want to display the size of a Char, the output gives me something like Ç ⌂ and I don't understand why. Do you have an idea?
1
2
3
4
5
6
7
#include <iostream>
#include <climits>

int main()
{
    std::cout << "char is " << (CHAR_BIT * sizeof(char)) << " bits.\n";
}
> However when I want to display the size of a Char

The types char, unsigned char, and signed char use one byte for both storage and value representation.
The number of bits in a byte is accessible as CHAR_BIT or std::numeric_limits<unsigned char>::digits
https://en.cppreference.com/w/cpp/language/memory_model#Byte


The following sizeof expressions always evaluate to 1:
sizeof(char)
sizeof(signed char)
sizeof(unsigned char)
sizeof(std::byte) (since C++17)
sizeof(char8_t) (since C++20)

https://en.cppreference.com/w/cpp/language/sizeof#Notes

Understand. Thanks ++
Topic archived. No new replies allowed.
Pages: 12