/ ******************************************************************* * * 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 * *******************************************************************/
file: /Techref/language/ccpp/Cref/EXAMPLES/const2.c, 0KB, , updated: 1997/4/21 08:52, local time: 2024/12/23 02:48,
18.224.38.170:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/language/ccpp/Cref/EXAMPLES/const2.c"> language ccpp Cref EXAMPLES const2</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.