Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What's the difference between char and int in C language of single chip microcomputer?
What's the difference between char and int in C language of single chip microcomputer?
In the C language of single-chip microcomputer, both char and int are data types, but their data ranges and functions are quite different.

Char type is usually used to represent character data, such as letters, numbers, symbols, etc. In MCU, the char type usually occupies 1 byte (8 bits), and its data range is generally-128 to 127 or 0 to 255. Variables of type char are usually used to store a single character or string.

Int type is usually used to represent integer data, such as integers. In MCU, the size of int type is usually 2 bytes (16 bits), and its data range is generally -32768 to 32767 or 0 to 65535. Variables of type int are usually used to store integer data.

So the difference between char and int mainly lies in data range and function. In the C language of single chip microcomputer, char type is usually used to store character data, and int type is used to store integer data. It should be noted that char-type variables can be converted into int-type variables by forced type conversion (such as (int)ch), but it may lead to the loss of data accuracy.