Turbo C large character array
don provan
donp at na.excelan.com
Wed Aug 1 05:27:41 AEST 1990
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"...)
don provan
donp at novell.com
More information about the Comp.lang.c
mailing list