Chapter:C const

From Juneday education
Jump to: navigation, search

Exercises const


Compile the file const-int-01.c to make sure it works.

Change the value of the variable i on a line after the initialisation and recompile. Does it work? Why?


Declare a pointer to int variable. Call the variable harold (after the famous author), Assign the variable harold the address of i.

Assign 129 to the memory address harold points to - you need to dereference harold to do this. Does the compile and produce a binary?


We shall now change the assignment to harold a bit. Typecast the address of i like this:


Does it work? Why?