Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!wuarchive!udel!freezer!gdtltr From: gdtltr@freezer.it.udel.edu (Gary Duzan) Newsgroups: comp.lang.c Subject: Re: Turbo C large character array Keywords: sizeof Message-ID: <26332@nigel.udel.EDU> Date: 1 Aug 90 09:33:37 GMT References: <1990Jul27.193520.4689@ux1.cso.uiuc.edu> <6819@ozdaltx.UUCP> <1627@excelan.COM> Sender: usenet@ee.udel.EDU Reply-To: gdtltr@freezer.it.udel.edu (Gary Duzan) Followup-To: alt.religion.computers Distribution: comp Organization: Brain Dead Innovations (BDI) Lines: 43 In article <1627@excelan.COM> donp@novell.com (don provan) writes: =>In article manning@gap.caltech.edu (Evan Marshall Manning) writes: =>>doug@ozdaltx.UUCP (Doug Matlock) writes: =>>>x = (char **)malloc(num_rows*sizeof(char)); =>> ^^^^^^^^^^^^ try sizeof(char *)!!!! => =>Actually, i prefer => => char **x; => x = (char **)malloc( num_rows * sizeof *x ); => =>Since the type of x has already been defined, why duplicate that =>information in the malloc? In general, i avoid sizeof(type), since =>there's almost always a specific example of type at hand, and normally =>it is in fact that specific example i want to know the size of, not =>the generic type. (And, of course, i'd *never* use a name like "x"...) => I think sizeof(type) is probably more popular (with me, at least) because it keeps the function call/macro "look and feel". It seems strange to have an identifier-looking operator when you are used to having funky symbol combination operators. For similar reasons I will tend to use "return(foo);" rather than "return foo;". Followups to alt.religion.computers. Gary Duzan Time Lord Third Regeneration p.s. But then again, I indent with tabs, so what could I know? :-) p.p.s. I won't use "x" either, but I'm not beyond using "tmp" (though usually as "tmpint", "tmppint", "tmpfoobar", etc.) GD,TL,TR -- gdtltr@freezer.it.udel.edu _o_ -------------------------- _o_ [|o o|] If you can square, round, or cube a number, why not sphere it? [|o o|] |_O_| "Don't listen to me; I never do." -- Doctor Who |_O_|