From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20010 invoked by alias); 28 Oct 2005 18:22:03 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 19298 invoked by uid 22791); 28 Oct 2005 18:21:55 -0000 Received: from ss46.shared.server-system.net (HELO ss46.shared.server-system.net) (64.207.180.3) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 28 Oct 2005 18:21:55 +0000 Received: from [10.15.2.211] ([200.122.157.119]) (authenticated bits=0) by ss46.shared.server-system.net (8.12.11/8.12.11) with ESMTP id j9SILj2x028173; Fri, 28 Oct 2005 11:21:47 -0700 Message-ID: <436263FA.3010103@gmail.com> Date: Fri, 28 Oct 2005 18:22:00 -0000 From: ework0 User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050930) MIME-Version: 1.0 To: Christoph Bussenius , gcc-help@gcc.gnu.org Subject: Re: Pointers to int References: <4362255E.90303@racsa.co.cr> <20051028160530.GE6673@opaque.pepe> In-Reply-To: <20051028160530.GE6673@opaque.pepe> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-10/txt/msg00216.txt.bz2 Hello, Christoph Bussenius wrote: >On Fri, Oct 28, 2005 at 07:19:26AM -0600, Fabio Andres Miranda wrote: > > >>Can anyone explain to the list how this pointers to int work: >> int *p; >> p = (int *)(array); >> for (i = 0; i < arraysize - 1; i += 4) >> *p++ = j - 8; >> *p = 0x0; >> >>P is defined as a pointer to a int. Then, it points to (the beginning ? >>) a char array. >>What is the result of perform the instruction: *p++; ? >> >> > >As postincrement (++) has higher priority than dereference (*), p++ is >what will be evaluated first. So p will be incremented by the size of >an integer (probably 4). After that, p will point to the second integer >of the array, i. e. array[1]. Now you use * to access that very >location and store j-8 there. > > > Regarding this issue, I understand the priorities of operands, I dont have clear what does the '++' operator increments: a. The memory location (ej: If it was 0x01, now it is 0x02); b. The value contained in the memory location p is point to? Can anyone provide a simpler illustrative examples regarding this operations? I think it would be great for the records of the list, Best regards, ework0