c 定义字符串类型变量_C字符串变量类型

c 定义字符串类型变量

c 定义字符串类型变量

[rps-include post=6557]

[rps-include post = 6557]

String is multiple characters added together. “Hi Poftut” is a string. Actually C do not direct String type but character type is used to store single and multiple characters.

字符串是将多个字符加在一起。 “ Hi Poftut”是一个字符串。 实际上,C并不直接指示String类型,而是使用字符类型存储单个和多个字符。

字符 (Character)

Character types is defined with char keyword. Single character will hold 1 byte in the memory. Character type normally hold ASCII characters but third party libraries provides support for different character types like UTF-8, UTF-16 etc.

字符类型用char定义 关键词。 单个字符将在内存中保留1个字节。 字符类型通常包含ASCII字符,但是第三方库提供对不同字符类型的支持,例如UTF-8,UTF-16等。

char mychar=’a’;

char mychar ='a';

(String)

As stated above string is a list of character types. We can define string like below.

如上所述,字符串是字符类型的列表。 我们可以如下定义字符串。

char name[6]={'i','s','m','a','i','l'};

Previous definition will create an char array which is equal to string. Above definition may seem a little bit error prone. We can define string more practical and less error prone like below.

先前的定义将创建一个等于字符串的char数组。 上面的定义似乎容易出错。 我们可以像下面这样定义更实用,更不易出错的字符串。

char name[]="ismail";

[rps-include post=6557]

[rps-include post = 6557]

LEARN MORE  Python Type Function with Examples
了解更多带有示例的Python类型函数

翻译自: https://www.poftut.com/c-string-variable-type/

c 定义字符串类型变量