This seemed easy enough to do, but it doesn't work. It compiles but it does not actually switch the values, and it gives me a "debug assertion error" and THEN it crashes, so be warned before you try running this
Code:
#include <iostream>
#include <conio.h>
#include <windows.h>
using namespace std;
void Swap(int*x, int*y);
int main() {
int x, y;dd
cout << "In main, x is " << x << " y is " << y << endl;
Swap(&x, &y);
cout << "After swap, x is " << x << " y is " << y << endl;
exit(1);
return 0;
}
void Swap(int *x, int *y) {
int *temp = new int;
*temp = *x;
*x = *y;
*y = *temp;
delete[] x;
x = NULL;
delete[] y;
y = NULL;
}
actually DON'T run this if you don't have to, jus tell me what I am doing wrong with your magical brain powers.