[OCLUG-devel] Re: [OCLUG] C - Pointer assignment
Chris Smith
cbsmith at gmail.com
Mon May 23 10:06:05 PDT 2005
Following up to oclug-devel as that's probably the more appropriate forum.
On 5/23/05, Doug Jolley <ddjolley at gmail.com> wrote:
> myPtr=(array+1);
>
> However, I'm not sure how I can go the other way and perform an
> assignment. Conceptually, I'd like to do something like:
>
> (array+1)=myPtr;
>
> IOW, I'd like to assign myPtr to the second element in the array (the
> first element being element 0). Of course, the compiler gives some
> complaint about a bad lvalue which I totally understand and expect.
> It's just that I don't know what to do about it. Can someone tell me
> how I can get this task done? Thanks.
I'm guessing you want to assing the value *pointed to* by myPtr to the
second element of the array. In that case, you can just use the
standard array syntax and reference the pointer:
array[1] = *myPtr;
--
Chris
More information about the OCLUG-devel
mailing list