Home >Backend Development >C#.Net Tutorial >What data type is char?

What data type is char?

藏色散人
藏色散人Original
2019-06-03 09:37:3625306browse

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.

What data type is char?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn