From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/EXAMPLES/const2.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 reference/C/EXAMPLES/const2.c (limited to 'reference/C/EXAMPLES/const2.c') diff --git a/reference/C/EXAMPLES/const2.c b/reference/C/EXAMPLES/const2.c new file mode 100644 index 0000000..249a071 --- /dev/null +++ b/reference/C/EXAMPLES/const2.c @@ -0,0 +1,33 @@ +/******************************************************************* + * + * Purpose: 'const' example. This code shows that making a + * variable 'const' only tells the compiler to not + * allow reassignment of the variable. The data is not + * in a special location, it can still be altered. + * + * This code may cause compiler warning messages + * but will compile and run. + * + * Author: M J Leslie. + * Date: 03-Mar-97 + * + *******************************************************************/ + +main() +{ + const int Men = 10; + int *Women = &Men; + + *Women = 20; + + printf("There are %d men\n", Men); + +} + +/******************************************************************* + * + * Result. + * + * There are 20 men + * + *******************************************************************/ -- cgit v1.2.3-54-g00ecf