Pointer function help

The assignment is : the following function uses reference variables as parameters. rewrite the function so it uses pointers instead of reference variables and then demonstrate the function in a complete program

int doSomething(int &x, int &y)
{
int temp =x;
x = y *10;
y = temp * 10;
return x + y;
}

what am i doing wrong when calling the function? when i compile it doesnt work correctly

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 #include <iostream>
#include <cstdlib>
using namespace std;
int dosomething();

int dosomething(int* x, int* y)
{
      int temp = *x;
      *x = *y * 10;
      *y = temp * 10;
      return *x+*y;
}

int main ()
{
int x,y;
cout << "Please enter a number" << endl;
cin >> x;
cout << "Please enter another number" << endl;
cin >> y;





dosomething(&x, &y);
cout << (x + y) << " = x(" << x << ") + y(" << y << ")\n" << endl;
system("Pause");
return 0;
}

What leads you to believe it isn't working correctly? What data are you trying with it, what are you getting out, and what are you expecting?
Topic archived. No new replies allowed.