3

Programming in a nutshell

Comments
  • 5
    Pointers, my friend.

    You should learn how variables work in their different contexts.
  • 1
    @CoolSonu39 as the others said: You need to use pointers. By default function basic type parameters are "pass-by-value", which means only the values of a and b are copied. When you change them in the function, they are not changed outside of it.

    void swap(int * a, int * b) {
    int * tmp = a;
    a = b;
    b = tmp;
    }
  • 1
    sorry guys, the only thing (he and) you missed is that he is debugging noswap instead of swap 😁
  • 0
    I already have 3 memes in my feed. Joke/meme please
Add Comment