Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!labrea!sri-unix!ctnews!pyramid!prls!philabs!gcm!dc From: dc@gcm (Dave Caswell) Newsgroups: comp.sys.mac.programmer Subject: Re: I thought I knew C, but... Message-ID: <497@white.gcm> Date: 4 Jun 88 05:01:07 GMT References: <341STORKEL@RICE> <366@dbase.UUCP> Reply-To: dc@white.UUCP (Dave Caswell) Organization: Greenwich Capital Markets, Greenwich, CT Lines: 21 In article <366@dbase.UUCP> drc@dbase.UUCP (Dennis Cohen) writes: . .As noted, it wanted single quote. around WORD rather than double quotes. That .is because mylist[0] is a 4-byte quantity known as an OSType rather than a .string (in Pascal, Packed Array [0..3] of Char). By putting single quotes .around WORD, the compiler treated it properly (:->) as a long, while with .double quotes, you had a 5-byte quantity (trailing null) which was aligned .improperly. BTW: This is a very common mistake among the C programmers I've No, it doesn't have anything to do with alignment. mylist = "word" assigns the address of an array to mylist. If mylist was char * rather than long you could assign "any length phrase to it". It doesn't have anything to do with trailing nulls or the length of the phrase or alignment or anything like that; and it certainly wouldn't work if you were to assign a 3 letter word to it It isn't a problem of 4 byte versus 5 byte. In the case of mylist = "word" you are assigning the memory location where "word" is stored rather than the characters 'word'. -- Dave Caswell Greenwich Capital Markets uunet!philabs!gcm!dc If it could mean something, I wouldn't have posted about it! -- Brian Case