Path: utzoo!attcan!uunet!dalcs!aucs!peter From: peter@aucs.UUCP (Peter Steele) Newsgroups: comp.sys.mac.programmer Subject: Re: I thought I knew C, but... Message-ID: <1098@aucs.UUCP> Date: 30 May 88 12:40:39 GMT References: <341STORKEL@RICE> Organization: School of Computer Science, Acadia Univ., Nova Scotia Lines: 32 > right? WRONG. When compiling, it gives a "warning: illegal combination of > pointer and integer" error on the line containing mylist[0]="WORD". So, I > try all kinds of things to fix it, until I've almost driven myself crazy. Then > I change the offending line to the following: > mylist[0]='WORD'; > Just changing the double quotes to single quotes makes everything work fine. No > compiler warnings, and MacWrite files do indeed show up in the dialog box. > So, my question is WHY? What is the big difference between single and double > quotes, and how do you know when to use them? There is a *big* difference between single and double quotes. Double quotes create a "constant" pointer to an area of memory containing the indicated characters. Such an expression consequently should be assigned to a pointer. The file types list is *not* an array of pointers to char, it is an array of 4 character vectors. The compiler was quite right to complain about your first attempt. By changing the double quotes to single quotes, the problem goes away because you are now creating an integer constant consisting of four bytes--'W', 'O', 'R', and 'D'. Code like this would not necessarily even compile on all systems. Whatever integer value this constant represents is assigned directly to mylist[0], which is exactly what you want. Sorry to post this. Our mailer rarely can find who to send messages to... -- Peter Steele, Microcomputer Applications Analyst Acadia University, Wolfville, NS, Canada B0P1X0 (902)542-2201x121 UUCP: {uunet|watmath|utai|garfield}dalcs!aucs!Peter BITNET: Peter@Acadia Internet: Peter%Acadia.BITNET@CUNYVM.CUNY.EDU