char Character type and byte unit

char Character type and byte unit

char represents characters and defines C's byte: sizeof(char) is 1, but CHAR_BIT need not be 8. The three char types are distinct; char signedness varies.

CategoryType specifiers
KindKeyword / Statement
C standardC89 / C90

📝 Syntax

char c = 'A';

▶ Example

Edit the C code below and click Run; the server compiles and executes it:

Output:

letter = A
sizeof(char) = 1
CHAR_BIT = 8
ℹ️ Info The standard guarantees sizeof(char) = 1. CHAR_BIT = 8 reflects the common GCC 10.2 target; other implementations may use a different byte width. This C89 example casts the sizeof result to unsigned long and prints it with %lu.

📚 Related Tutorials

❓ FAQ

QIs a byte in C always 8 bits?
ANot necessarily. A C byte is an addressable storage unit whose bit count is given by CHAR_BIT in limits.h. Many platforms use 8 bits, but the standard permits other widths.
QIs plain char signed or unsigned by default?
AThat is implementation-defined. Plain char, signed char, and unsigned char are three distinct types. If code depends on sign or numeric range, explicitly choose signed char or unsigned char.
QWhy is sizeof(char) always 1?
Asizeof reports sizes in C-defined bytes, and char occupies exactly one such byte. The value 1 says nothing about 8-bit width or identical physical storage widths across platforms.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏