Using sizeof() on a parameter array

Jim Seidman jseidman at jarthur.Claremont.EDU
Sun May 19 02:25:02 AEST 1991


I ran into this using Microsoft C 6.00A, and wanted to know if this was
a bug in MSC or the way an ANSI C compiler really should work.  Consider
the following function:

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).

The ANSI K&R doesn't address this issue explicitly.  Any definitive
answers on what should happen?

-- 
Jim Seidman, Headland Technology, 46221 Landing Parkway, Fremont CA 94538
"It doesn't need to work.  They'll be paralyzed laughing at me."
							- The Doctor, "Shada"



More information about the Comp.lang.c mailing list