Hi,
I am a software engg. working as developer.Right now I am working in compiler validation project.
And my question is -
what are the possibilities of writing C codes using the keyword 'const'.I have written some and need few more..Plz go thru and let me other ossibilities..
const int degrees = 360; /* degrees is constant */
int const degrees1 = 180; /* degrees is constant */
const float pi = 3.14;
const char quit = 'q';
int * const var1; /* The pointer is constant,
the data its self can change. */
const int * var2; /* the data can not be changed
but the pointer cannot */
int const * var3 /* same as above */
const char * const Var4; /* both pointer and the data are read only */
char const * const Var5; /* same as above */
//void test1() const; /* function do not modify any variables */
const int * test2(); /* function returns an adress that
could not be modified */
void test3(const int *i); /* the parameter being passed as a adress
could not be modified by the function */
const int arr1[]={1,2,3,4,5,6,7};
char const *arr2="coderzone";
typedef struct member
{
char name[20];
long phno;
};
const struct member M1 = {"Marino" , 62627000};
struct member * const M2 = {"John" , 2786900};
const struct member * const M3 = {"Smith",57361777};
union single
{
int I1;
char C1;
};
const union single S1 = {97};
union single * const S2 = {'A'};
const union single * const S3 = {'0'};
Thanks in Advance..