/ ******************************************************************* * * 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/11/5 16:08,
18.191.103.117:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©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://linistepper.com/techref/language/ccpp/CREF/EXAMPLES/const2.c"> language ccpp CREF EXAMPLES const2</A> |
Did you find what you needed? |