Why do I get errors on implementing this program? I'm unable to find anything wrong here.
#include <iostream>
using namespace std;
void exchange(point& p);
int main()
{
struct point
{
int a, b;
};
point one = {1,2};
exchange(one);
cout << one.a << " , " << one.b;
return 0;
}
void exchange(point& p)
{
int temp;
p.a = temp;
p.a = p.b;
p.b = temp;
}
I get errors in another program too, that implements Structures in a similar way.