Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: argc loop [tlug]



"Stephen" wrote:

> Jim writes:

>  > Also tolerable, but less readable, would be: 
>  > 
>  >     while (*argv++!=(char *)0)

> If you insist on accessing the argv array, the correct idiom is
> 
>     do { ... } while (*argv++ != NULL);

When argc is zero, the former code "does nothing gracefully", 
while the latter code requires another test inside the loop 
to avoid dereferencing a null pointer. 



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links