Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!ctrsol!seth From: seth@ctr.columbia.edu (Seth Robertson) Newsgroups: comp.lang.c Subject: sizeof(array) Message-ID: <1989Aug22.024808.17913@ctr.columbia.edu> Date: 22 Aug 89 02:48:08 GMT Reply-To: seth@ctr.columbia.edu (Seth Robertson) Organization: Columbia University Center for Telecommunications Research Lines: 52 Hi. I have a problem in that when I pass an array, it loses track of its size. ex. ------------------------------------------------------------------ unsigned long testcode[] = { 3422617600, 3422752768, 513998896, 2684354560, 0 }; main() { int size = sizeof(testcode) / sizeof(testcode[0]); printit(testcode); printf("Loading %d %d %d\n",size,sizeof(testcode),sizeof(testcode[0])); } printit(code) unsigned long code[]; { int size = sizeof(code) / sizeof(code[0]); printf("Loading %d %d %d\n",size,sizeof(code),sizeof(code[0])); } ---------------------------------------------------------------------- Output: Loading 1 4 4 <-- Incorrect Loading 5 20 4 <-- Correct I guess I understand what it is does (only passing the address, not any additional information), but how do I get it to do what I want? In case you are wondering, yes, there are good reasons for making `printit' a subroutine, for passing code as a parameter instead of explicitly naming testcode, and for making testcode a global automatically initialized variable (variable only at compile time, obviously) sized array. -- -Seth Robertson seth@ctr.columbia.edu