Using sizeof() on a parameter array

Doug Gwyn gwyn at smoke.brl.mil
Mon May 20 14:13:22 AEST 1991


In article <12151 at jarthur.Claremont.EDU> jseidman at jarthur.Claremont.EDU (Jim Seidman) writes:
-void test(char param[80]) {
-    char local[80];
-    printf("sizeof(param) = %d\n", sizeof(param));
-    printf("sizeof(local) = %d\n", sizeof(local));
-}
-Now, I thought that this should print out the same size for both, namely
-80.  But according to MSC, local has a size of 80, and param has a size
-of 2 (the size of a pointer).

MSC is right.  The parameter DOES have type pointer-to-char; you've
just written in in an opaque way.



More information about the Comp.lang.c mailing list