C Programming Reference


C Programming Reference >> C Basic Tutorials >> C Keywords Home >>

consti

30/12/06 -  Views - Ratings :   3.48 of 5 / 155 Votes

This used to declare a variable constant. This means that the value of variable is unchangable. It can also be used to declare a pointer constant in that case value pointed by that pointer is unchangable. This specially desirable when we want the value passed by refrence to a function remain unchanged under all circumstances.

Code -
void function (void)
{
const int a = 10;
printf ("%d",a);
\\ a = 20;  If you remove the comments symbol this will generate an compile time error.
  
}

Back To Top


      

 

 

© 2006 cencyclopedia.com