Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!mtune!codas!usfvax2!chips From: chips@usfvax2.UUCP (Chip Salzenberg) Newsgroups: comp.sys.ibm.pc Subject: Re: ** Re: MSC 4.0 Large Model ** Original Posters problem solved!!! Message-ID: <822@usfvax2.UUCP> Date: Fri, 21-Aug-87 16:35:11 EDT Article-I.D.: usfvax2.822 Posted: Fri Aug 21 16:35:11 1987 Date-Received: Sun, 23-Aug-87 06:36:24 EDT References: <10400006@altger.UUCP> <72@cunixc.columbia.edu> Organization: AT Engineering, Tampa, FL Lines: 43 Summary: sizeof(char) == 1 In article <72@cunixc.columbia.edu>, nwc@cunixc.UUCP writes: > > Yes I started the whole thing :-) And I am glad to announce my code runs!!!!! > > > I pulled from all the answers to my question and these were the key > ingredients: > > 1) Use NULL not 0 as often as applicable. There was a _big_ discussion about this in comp.lang.c. Actually, K&R defines NULL as `an integral value that evaluates to zero'. If you pass NULL as a pointer parameter, YOU HAVE TO CAST IT. This rule is necessary beause some implementations of C for word-addressed machines have different sizes for `char *' and `int *'; on those architectures there is no single integral value which is the same size as all pointers. So, cast, cast, and cast again. Of course, if portability is not important to you -- `NEVER MIND.' :-) > 2) use sizeof()'s in malloc()'s and calloc()'s i.e.: > char *s,*s2; > s2 = "hello"; > s = malloc((strlen(s2)+1)*sizeof(char)); > This is unnecessary. It is always true that sizeof(char) == 1, unless you've #define'ed char to something else, in which case there's trouble in River City. > 3) Make a ".h" file and externally declare ALL your functions > so that the return type is clear before a function it called. This is good advice. NOTE TO ALL FLAME-PRONE READERS: Before you follow up this article, WAIT! Run, don't walk, to comp.lang.c. The people there can answer any C question that has an answer. [Warning: this article has been equipped with a Corbomite device. Anyone directing flames at this article will be hit with counterflames of equal force] -- Chip Salzenberg UUCP: "uunet!ateng!chip" or "chips@usfvax2.UUCP" A.T. Engineering, Tampa Fidonet: 137/42 CIS: 73717,366 "Use the Source, Luke!" My opinions do not necessarily agree with anything.