Ian Collins
4/7/2011 8:06:00 PM
On 04/ 8/11 07:56 AM, Lew Pitcher wrote:
> On April 7, 2011 15:51, in comp.lang.c, Owner@Owner-PC.com wrote:
>
>> Can this code determine number of aruments?
>>
>> sizeof argv / sizeof argv[0]
>>
>> I'd appreciate any comments
>
> Assuming that you use argv in the sense of the 2nd argument to main()
> i.e.
> char **argv;
> or
> char *argv[];
>
> then, NO]
> sizeof argv / sizeof argv[0]
> does not give you the number of arguments in the argv[] array.
>
> It /does/ give you
> the number of char * pointers that can fit in a char ** pointer;
> a singularly useless tidbit of information.
No, it gives you the size of a char**.
--
Ian Collins