C Identifier

Identifier is a name of functions, variables and user defined items. compiler is understand identified by its name and its data type when compilation of source code.

C identifiers


  Example of identifiers 
/*Header file*/
#include <stdio.h>

//get_salary and id is identifiers
float get_salary(int id){
int main(){
  //Book is identifiers
  struct Book{
    int pages;
    float weight;
    double price;

  // counter is identifiers
  int cunter=10;
  //salary is identifiers
  float salary=100;

  return 0;

Rules of identifiers

1) Identifier name should not be same as keyword.
2) Identifier are contains char, number and underscores.
3) First character of an identifier is start with alphabets(a to z or A to Z) and underscore (_).
4) Digit are not allowed to start variable name..
5) There are no rule to define the length of identifier. but there are only single words not use space char to separate identifiers.
6) Identifiers are case sensitive. example.

  Case sensitive
/*Header file*/
#include <stdio.h>
int main(){
  /*Entry point of program*/

  /*Variables and identifiers*/
  int num=10,Num=20,nuM=30,NUM=40;
  printf("%d  %d  %d  %d",num,Num,nuM,NUM);
  return 0;


10 20  30  40
case sensitive example
  Example of valid identifires
#include <stdio.h>

int main(){
  int __=1; //__ are valid
  int _=2;// _ valid valid
  int num=3; // num is valid
  int int_1=4; //int_1 is valid
  char c='a';//valid
  char C='b'; //case sensitive.( c,C);
  char _char_var='c';
  float floatVar=1.0f; //camel case are valid

  printf("__  : %d\n",__);
  printf("_   : %d\n",_);
  printf("num : %d\n",num);
  printf("int_1 : %d\n",int_1);
  printf("c : %c\n",c);
  printf("C : %c\n",C);
  printf("_char_var: %c\n",_char_var);
  printf("floatVar : %f\n",floatVar);


__  : 1
_   : 2
num : 3
int_1 : 4
c : a
C : b
_char_var: c
floatVar : 1.000000

Tips for Good Programming Practice

1) Provide a meaningful name of identifiers.

float salary;
int age;
char status;
char employee_list[10];
int *auxiliary_ptr;

In form of function

int account_list(int employee){}
float check_balance(int employee_id){}
int add_items(int size, int values){}

2) Try to given length of variable less than 32 char. because some of c compiler cannot differentiate in variable. when the length of variable is more than 32 char.

3) function name and variable name should not same. otherwise compiler produce error. look at this example.

In this program function name and variable name are same. 
then gcc compiler produce error.
#include <stdio.h>
int sum(int a,int b){
  return a+b;
int main(){
  int sum=sum(1,2);
error: called object ‘sum’ is not a function or function pointer. 

Note that if we are use function pointer then this will valid. but in simple case produce an error.

© 2019, regularcodes.com, All rights reserved