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

What data type is char?

藏色散人
Release: 2019-06-03 09:37:36
Original
25293 people have browsed it

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";
Copy after login

can be compiled

, but if you use

signed char *p="abcd";
Copy after login

or

unsigned char *p="abcd";
Copy after login

, 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码*/
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template