How to swap between two variables?

Discussion in 'Case Modding' started by RoseVeera, Oct 13, 2011.

  1. RoseVeera

    RoseVeera

    Joined:
    Oct 13, 2011
    Messages:
    1
    hi..i'm very new to c programming. and i wanna know why can't i compile this code? I'm using dev c++.

    void change(int *,int*);

    int main ()
    {
    int a=2,b=5;
    printf("Before : a=%d,b=%d\n",a,b);

    change(&a,&b);

    printf("After : a=%d,b=%d\n",a,b);
    return 0;
    }

    void change(int *a,int *b)
    {
    a += *b;
    *b = *a-*b;
    *a = *a-*b;
    }
    RoseVeera, Oct 13, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anthony Boor

    "about:" variables

    Anthony Boor, Jul 8, 2004, in forum: Firefox
    Replies:
    2
    Views:
    638
    Jan Steffen
    Jul 8, 2004
  2. Chaos Master
    Replies:
    0
    Views:
    911
    Chaos Master
    Jul 10, 2004
  3. dt1649651@yahoo.com

    variables in ACL ?

    dt1649651@yahoo.com, May 23, 2005, in forum: Cisco
    Replies:
    2
    Views:
    647
    Barry Margolin
    May 24, 2005
  4. Peter Guhl
    Replies:
    4
    Views:
    2,325
    Peter Guhl
    Jul 5, 2005
  5. Dmitriy Lapshin [C# / .NET MVP]

    Variables in catch(...) clauses?

    Dmitriy Lapshin [C# / .NET MVP], Feb 26, 2004, in forum: MCSD
    Replies:
    9
    Views:
    538
    The Poster Formerly Known as Kline Sphere
    Mar 2, 2004
Loading...

Share This Page