Path: utzoo!attcan!uunet!husc6!bloom-beacon!apple!voder!kontron!optilink!cramer From: cramer@optilink.UUCP (Clayton Cramer) Newsgroups: comp.lang.c Subject: Use of Const keyword in ANSI C Message-ID: <441@optilink.UUCP> Date: 7 Sep 88 23:39:34 GMT Organization: Optilink Corporation, Petaluma, CA Lines: 37 I'm starting to use the 'const' keyword with the Microsoft V5.1 C compiler. I've found something that may be a bug, or it may be that I don't adequately understand 'const'. I've defined a structure: typedef struct Tag { const int A; short B; const char* C; } TestType; TestType Test1 = {10, 10, "test case"}; Test1.A = 5; /* compiler complains about this -- good */ Test1.B = 20; /* compiler accepts this -- fine */ Test1.C = "not a test case"; /* compiler accepts this -- bad */ Should the attempt to set Test1.C to point to another string cause a complaint from the compiler? If I redefine the structure the same as above but with: const char C[20]; and a statement: Test1.C[0] = '0'; the compiler complains (correctly) "lval specifies 'const' object". So have I missed something here in my understanding of 'const', or is the Microsoft compiler broke? Clayton E. Cramer ..!hplabs!pyramid!kontron!optilin!cramer