Re: #define....
- From: Ulrich Eckhardt <eckhardt@xxxxxxxxxxxxxx>
- Date: Fri, 22 Jul 2005 10:35:27 +0200
remco wrote:
> "Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:9A5116B7-46B0-4D5D-AC9C-6BB55DBA1360@xxxxxxxxxxxxxxxx
>>
>> #define dim(x) (sizeof(x) / sizeof(x[0]))
>>
>> I am trying to understand what this line has to do with the rest of the
>> code.
[...]
> For instance, if you want to get the number of items you would use that
> snippit.
> You'll find it all over ancient C/C++ code perhaps in a more familar form:
>
> DWORD mydwords[[100];
>
> DWORD numberOfBytes = sizeof(mydwords); // will be 100 * however long a
> DWORD is (4)
> DWORD numberOfItems = sizeof(mydwords)/sizeof(mydwords[0]); // number will
> be 100
Just for your info, the brackets are not necessary as sizeof is not a
function and you sometimes see the * operator instead of []:
size_t const count = (sizeof array)/(sizeof *array);
Uli
.
- Follow-Ups:
- Re: #define....
- From: remco
- Re: #define....
- References:
- #define....
- From: Robby
- Re: #define....
- From: remco
- #define....
- Prev by Date: Re: Platform Manager failed to queue CEMON pkg for download
- Next by Date: drawing data from pwi
- Previous by thread: Re: #define....
- Next by thread: Re: #define....
- Index(es):
Relevant Pages
|