OK I am simply trying to pass variables by pointers but for some reason it doesn't work, can someone tell me what to change?
Code:
#include <iostream>
using namespace std;
void Swap(int*, int*);
int main(void) {
int x, int y, int swapped;
cout << "Enter two variables" << endl;
cin >> x >> y;
cout << "You have entered " << x << " and " << y << "!";
Swap(&x,&y);
cout << "X is now " << x << " Y is now " << y << endl;
return 0;
}
void Swap(int *x, int *y) {
int *temp;
*temp = *x;
*x = *y;
*y = *temp;
}
Thanks if you can help me...it is really important that I can be able to EFFECTIVELY pass variables using pointers. When you get into large programs simply passing the variables themselves can slow the program down.