Path: utzoo!utgpu!watmath!iuvax!rutgers!uwvax!tank!s170 From: s170@tank.uchicago.edu (harmon g washington) Newsgroups: comp.sys.mac.programmer Subject: Seemingly equivalent code fragments in C Keywords: C pointers Lightspeed int Message-ID: <4882@tank.uchicago.edu> Date: 7 Aug 89 19:35:26 GMT Organization: University of Chicago Lines: 36 In programming the Macintosh apple menu I tried to create the Apple symbol usingthe following code: void MenuInits() { int *bittenApple; *bittenApple = 0x0114; /* create Pascal string 1 byte long */ AppleMenu = NewMenu(ApplID, bittenApple); . . } /* menuinits() */ THIS CODE DID NOT WORK! Instead of the Apple logo I got a random string of junkIt seemed it should have work: defining a pointer to an int; and then defining the item it points to. Now the following fragment of code DID work: void MenuInits() { int *bittenApple, xx; xx = 0x0114; bittenApple = &xx; AppleMenu = NewMenu(ApplID, bittenApple); . . } /* menuinits() */ the following code also worked: void MenuInits() { int bittenApple; bittenApple = 0x0114; ApplMenu = NewMenu(ApplID, &bittenApple); . . } /* menuinits() */ where #define ApplID 1 and MenuHandle ApplMenu; I would thind the three code fragments are equivalent ways of doing the same thing in C. Why did not the first code fragment work? --- Harmon Washington