I want to swap two variables using pointers without any function call or any temp variable.
My current code is:
void main()
{
int a=1, b=2, *c;
cout << a << b << endl;
*c = a;
a = b;
b = *c;
cout << a << b << endl;
getch();
}
The code works on Turbo C++ but not on Visual Studio, plus I read it was bad practice to have an uninitialized pointer variable.
So can anyone tell me what changes I need to make in this code for it to work on visual studio? If there is a better way please tell.
Thanks..