Re: Getting array size

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Phil Frisbie, Jr. (phil_at_hawksoft.com)
Date: 12/07/04


Date: Tue, 07 Dec 2004 14:58:48 -0800

Mark wrote:

> I'm writing a program that takes start up parameters, but when I try to get
> the size of the array, it always returns 4.
>
> int _tmain(int argc, _TCHAR* argv[])
> sizeof(argv) is always 4 no matter what.

You need more basic C lessons....

sizeof() is evaluated at compile time, and argv is a POINTER, which on win32 is
always 4 bytes (32 bits). argc already tells you how many entries are in argv,
so tell us what you are attempting to do.

> Thanks
> Mark

-- 
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com


Relevant Pages