From: G DOT DegliEsposti AT ads DOT it To: djgpp AT delorie DOT com Message-ID: Date: Thu, 5 Feb 1998 09:33:42 +0100 Subject: Re: Sizeof and pointers Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Precedence: bulk >void func(unsigned char *tmp) >{ >// BLAH BLAH >} > >How do i find how many bytes tmp is taking up in memory: > >the sizeof funtion returns 4 bytes, the reason being (i think) that it >is finding out how many bytes the pointer takes up in memory. I dont >want to use strlen(tmp) because the string may have a '\0' character. Not easy... in C strings do not exist (as language constructs): they are defined in a conventional way within the libraries. "char * tmp" actually means "the address of a data of type character" and *we* know wether the following addresses contain valid data or not but the compiler doesn't. This means there's no way that the compiler can know how many valid characters follow the one pointed by tmp. You have to tell. The fastest way is to add an argument to the function specifying how many valid chararcters tmp takes... void func(int len, unsigned char * tmp) { // ... } ciao Giacomo