📜  关键字和标识符的区别

📅  最后修改于: 2021-09-13 02:38:31             🧑  作者: Mango

关键词:
关键字是 C 语言中的特定保留字,每个保留字都有与之相关的特定特征。几乎所有帮助我们使用 C 语言功能的词都包含在关键字列表中。所以你可以想象关键字列表不会是一个小列表!
C中一共有32个关键字:

auto       break    case     char     const     continue
   default    do       double   else     enum      extern
   float      for      goto     if       int       long
   register   return   short    signed   sizeof    static
   struct     switch   typedef  union    unsigned  void
   volatile   while 

身份标识:
标识符用作命名变量、函数和数组的通用术语。这些是用户定义的名称,由任意长的字母和数字序列组成,其中一个字母或下划线 (_) 作为第一个字符。标识符名称的拼写和大小写必须与任何关键字不同。您不能使用关键字作为标识符;它们保留用于特殊用途。声明后,您可以在后面的程序语句中使用标识符来引用关联的值。可以在 goto 语句中使用一种特殊的标识符,称为语句标签。

关键字和标识符的区别:

SR. NO. KEYWORD IDENTIFIER
1 Keywords are predefined word that gets reserved for working progs that have special meaning and cannot get used anywhere else. Identifiers are the values used to define different programming items such as variables, integers, structures, unions and others and mostly have an alphabetic character.
2 Specify the type/kind of entity. Identify the name of a particular entity.
3 It always starts with a lowercase letter. First character can be a uppercase, lowercase letter or underscore.
4 A keyword should be in lower case. An identifier can be in upper case or lower case.
5 A keyword contains only alphabetical characters. An identifier can consist of alphabetical characters, digits and underscores.
6 They help to identify a specific property that exists within a computer language. They help to locate the name of the entity that gets defined along with a keyword.
7 No special symbol, punctuation is used. No punctuation or special symbol except ‘underscore’ is used.
8 Examples of keywords are: int, char, if, while, do, class etc. Examples of identifiers are: Test, count1, high_speed, etc.