Identifier Naming rules in C language

Last Updated :

Prerequisite – C Language Introduction
In C any name is called identifier. This name can be:

1. Variable name
2. Function name
3. Enum constant name
4. Micro constant name
5. Goto label name

And, any other data type name like, 
6. Structure 
7. Union
8. Enum names or Typedef name

Token

These are following rules that should follow:

  • Rule-1:
    Name of identifier can include only alphabets, digits, and underscore.

    Valid name: 
    earth, subtraction123, addition_of_integer
    
    Invalid name:
    multiplication@, mean value, output%number
  • Rule-2:
    First character of any identifier must be either alphabet or underscore.

    Valid name: 
    earth, _subtraction123, addition_of_integer
    
    Invalid name:
    3multiplication@, 33, 10_output
  • Rule-3:
    Name of identifier can not be any keyword of C program.

    Valid name: 
    INT, FLOAT
    
    Invalid name:
    int, float, enum
  • Rule-4:
    Name of identifier cannot be global identifier.

    Valid name: 
    _NAME_, _TOTAL_
    
    Invalid name:
    _TIME_, _DATE_, _SMALL_, 
    _PASCAL_, _LINE_, _LARGE_
  • Rule-5:
    Name of identifier cannot be register Pseudo variables.
  • Rule-6:
    Name of identifier cannot be exactly same as of name of function within the scope of the function.
  • Rule-7:
    Name of identifier is case sensitive, means Int and int are two different variables.
  • Rule-8:
    Only first 32 characters are significant of identifier name. That is identifier can not have more than 32 characters in its name.
  • Rule-9:
    Name of identifier cannot be exactly same as constant name which have been declared in header file of C and you have included that header files. Also, it cannot be eaxtly same as function name or data type name that we have declared in the header of C.

If you will not follow these rules while naming of identifier, then program will not compiler, i.e., there will be compilation error.

 

Please write comments if you find anything incorrect. A gentle request to share this topic on your social media profile.

Comment
Next Article
Mithlesh Upadhyay Published 11 May, 2020 · 2 min read

Mithlesh Upadhyay is a Computer Science and AI expert from Madhya Pradesh with strong academic background (BE in CSE and M.Tech in AI) and over six years of experience in technical content development. He has contributed tech articles, led teams, and worked in Full Stack Development and Data Science. He founded the w3colleges.org portal for learning resources.

Article Tags :

Similar Reads

  • What should we use void main() or int main() ?

    There is question that what should we use void main() or int main() ? void main() { /* ... */ } Or, int main() { /* ... */…

    2 min read
  • C Comments

    Prerequisite – C Language Introduction C comments explain code and improve readability. These do not affect program execution. You can use comments in C to clarify code and describe…

    1 min read
  • C Programming Language Standard

    Prerequisite – C Language Introduction The C programming language has various versions: C89/C90, C99, C11, and C18. C89/C90: Released in 1989/1990. It introduced key language features. C99: This…

    2 min read
  • Features of C Programming Language

    Prerequisite – C Language Introduction C is a simple language made in 1972 by Dennis Ritchie. It’s for system programming. C has low-level memory access, basic keywords, good…

    1 min read
  • C Language Introduction

    C is a programming language developed by Dennis Ritchie in 1972. It has a significant historical impact. It was originally created at Bell Laboratories of AT&T Labs for…

    4 min read
  • Code editors

    Code editors are where programmers spend most of their time. There are two main types of code editors: IDEs and Lightweight editors. IDEs (Integrated Development Environments) IDEs (Integrated…

    1 min read