Google News
logo
Embedded C - Interview Questions
Following are some incomplete declarations, what do each of them mean?
1. const int x;
2. int const x;
3. const  int  *x;
4. int * const x;
5. int  const * x const;
 
* The first two declaration points 1 and 2 mean the same. It means that the variable x is a read-only constant integer.

* The third declaration represents that the variable a is a pointer to a constant integer. The integer value can't be modified but the pointer can be modified to point to other locations.

* The fourth declaration means that the variable x is a constant pointer to an integer value. It means that the integer value can be changed, but the pointer can't be made to point to anything else.

* The last declaration means that the variable x is a constant pointer to a constant integer which means that neither the pointer can point to a different location nor the integer value can be modified.
Advertisement