void swap (int *px, int *py) {
int temp;
temp = *px;
*px = *py;
*py = temp;
}
that will swap two variables, which looks okay for me.
now if I change it to
void swap (int *px, int *py) {
int *temp;
*temp = *px;
*px = *py;
*py = *temp;
}
notice int *temp
this works anyway though, but temp is dereferenced without being initialized.
what value would this not work for?
like if i want to make a method called proc how could i gurantee the program will crash? I think I am supposed to leave something on the stack.
int main () {
int a = 1, b = 2;
proc(/* Some args might go here */);
swap(&a, &b);
}