Identifiers in C language | Rulers for defining Identifiers in C language
In C language we have only two types of words one type is keywords and other one is Identifiers.
Keywords are predefined words compiler know the meaning of these words we cannot use keywords for any other purpose.
Identifiers are user defined words and are used to give names to any entity like Functions, Variables, arrays,Structures,..etc.
Identifiers is unknown word to compiler if you are going to use Identifier then you have to define it’s meaning for example if your going to create Function then you need to write it’s Definition. so Identifiers are Unknown words.
We just learn What is Identifier but how to name a Identifier ? because your going to define your own variable, Function,.. anything then How compiler come to know this is an Identifier ? The answer is simple,. Every thing apart from the keywords are Identifiers.and we also have few Rules to defining Identifiers those are Described below.
Rules for naming Identifiers :
- The name should contains only Alphabets(lower and upper cases), Digits and Underscore( _ ).
- First character must be alphabet or underscore( _ ).
- First Character should not a Digit.
- The Name of an Identifier should not be a valid Keyword.
- Identifier must be smaller then 32 characters ( depends on Implementation).
- C is Case Sensitive Language so upper case letter and lower case letters are different that means VENKATESH , venkatesh, are completely different Identifiers.
Few Valid Identifiers examples..
Few Invalid Identifiers
4u First character should not be digit violating 3rd rule from above rules.
char char is a valid keyword violating 4th rule.
silly# # is not allowed violating 1st Rule.
silly codes no spaces are allowed.