Re: C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Pete Harlan
On Thu, May 16, 2002 at 09:02:25AM +0200, Perceval Anichini wrote: > When you write > argv + 1, the compiler will understand : compute the address > of argv, and add one time the size of the type which is pointed by argv. > I remember to you that argv[1] = argv + 1. Brackets are only syntactic > s

Re: C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Matijs van Zuijlen
On Thu, May 16, 2002 at 06:13:08PM +0930, Tom Cook wrote: > On 0, Perceval Anichini <[EMAIL PROTECTED]> wrote: > [snip] > > > Moreover, argv + sizeof (argv[1]) is equal to argv[4] (as sizeof (char*) = > > 4) ... > > > > > No. If that were so then you could not access the list of arguments > > >

Re: C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Tom Cook
On 0, Perceval Anichini <[EMAIL PROTECTED]> wrote: [snip] > > Moreover, argv + sizeof (argv[1]) is equal to argv[4] (as sizeof (char*) = > 4) ... > > > No. If that were so then you could not access the list of arguments > > to a main function as argv[0], argv[1], argv[2] etc. The compiler > > k

C's pointer arithmetic (Was Re: Setting effective UID for a shell script)

2002-05-16 Thread Perceval Anichini
>>>execv( argv[1], argv + sizeof( argv[1] ) ); >> Could you explain this? Why would this line be *more* correct than the precedent? > The second version makes the pointer arithmetic explicit and has the > correct type for the second argument. The first involves an implicit > cast from char*