Re: [Dev-C++] How to get the number of elements in an array
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2004-01-20 13:42:50
|
I tried that but it returns the size of the first element in the array (or whatever the pointer is pointing to). To set Size I called a function and it returns 320 (bytes required). This is most troubling as I should know this! lol Daniel >From: "Paul Muehlbach" <tr...@gm...> >To: "Daniel Glenfield" <sp...@ho...> >Subject: Re: [Dev-C++] How to get the number of elements in an array >Date: Tue, 20 Jan 2004 14:04:00 +0100 (MET) > > > This is an easy Q I know but I can't think how to do it... > > > > Size = 9; // Decided by a function but set to 9 for this example > > > > int* Buf = new int[Size]; > > > > int Tmp = sizeof(Buf); > > > > This can't be right. How do I get the size? Len(Buf) and Length(Buf) are > > not > > recognised (I thought they were functions but I guess not). > > > > Any thoughts? > > > >try > >Tmp = sizeof(*Buf); > >(sorry,but normally,i use c-array functions ^^°) > >traexx > >-- >+++ GMX - die erste Adresse für Mail, Message, More +++ >Bis 31.1.: TopMail + Digicam für nur 29 EUR http://www.gmx.net/topmail > _________________________________________________________________ It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger |