Turbo C large character array
Gary Duzan
gdtltr at freezer.it.udel.edu
Wed Aug 1 19:33:37 AEST 1990
In article <1627 at excelan.COM> donp at novell.com (don provan) writes:
=>In article <manning.649438172 at gap> manning at gap.caltech.edu (Evan Marshall Manning) writes:
=>>doug at 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 at 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_|
More information about the Comp.lang.c
mailing list