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
    Likes Received:
    0
    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. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.