Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: Incrementing int passed by reference



In <[EMAIL PROTECTED]> Ian Bell <[EMAIL PROTECTED]> writes:

>I am passing the address of an int into a function.

This is not the same thing as passing by reference (which is not supported
by C at all).

>I want to increment the int.  Code snippet
>
>void foo(int * pc)
>{
>    *pc++;
>}
>
>pc does not get incremented.  However if I do this:
>
>foor(int * pc)
>{
>    int temp;
>
>    temp = *pc;
>    temp++
>    *pc = temp;
>}

    (*pc)++;

would be enough.

>Is this a funny precedence thing with *?

What does your C book have to say on the topic?

Dan
-- 
Dan Pop
DESY Zeuthen, RZ group
Email: [EMAIL PROTECTED]
-- 
comp.lang.c.moderated - moderation address: [EMAIL PROTECTED]



<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.