Char is one of the weirder C/C integer data types. Others such as int/long/short, etc. default to signed when signed/unsigned is not specified. However, char is not specified as signed/unsigned in the standard. Compilation The compiler can be implemented as signed or unsigned. Some compilers, such as the pSOS compiler, can also specify whether it is a signed or unsigned number through a compilation switch.
Data type
Definition: Can be used in computer programming languages (c, c, java, VFP,, pascal, etc.) A basic data type that holds a single character.
In C/C, char is one of the weirder C/C integer data types, and there is a special language about char which is char *, which has special semantics in C/C. It is different from signed char * and unsigned char *. It is specifically used to refer to strings ending with '\0'
In C, you can try it with
char *p="abcd";
can be compiled
, but if you use
signed char *p="abcd";
or
unsigned char *p="abcd";
, it will not be compiled.
These are clearly explained in the C/C language standard or some classic books such as TheC Programing Language.
Judge the default char symbol of the compiler
#include <stdio.h> int main() { char c=-1; if(c<200){ printf("signed\n"); } else{ printf("unsigned\n"); } return 0; } /*char 还在pascal语言中应用。在Pascal语言中,字符常量是由单个字符组成,所有字符采用ASCII编码也称ASCII码*/
Field type editing
In MYSQL, the field type char refers to : A string represented by a fixed length of a specified length; for example, char (8), the database will use a fixed 1 byte (eight bits) to store the data, and strings with less than 8 bits will be followed by null characters.
Character conversion
The char function in excel is used to return the character corresponding to the numeric code. Its usage: =char (number)
Among them, the parameter number is the converted character code, between 0 and 255. char occupies one byte, which is 8 binary bits, but it represents It is a signed type, so the represented range is -128~127; uchar represents an unsigned type, so the represented range is 0~255.
Algebraic concepts
Char is the abbreviation of characteristic, which represents the characteristics of a ring or domain, that is, the smallest non-negative integer n such that ne=0. (e is the unit element).
The above is the detailed content of What data type is char?. For more information, please follow other related articles on the PHP Chinese website!