Trying to point to a function

I am not sure what is going on. All I am trying to do is call a function with pointers. It will not let me assign the pointer to the memory addresses. I am not sure whats going on. Thanks for your help in advance.

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
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <iomanip>
#include <conio.h>

using namespace std;

int dosomething (int, int);

int main()
{
	int *x, *y, n1, n2;
	
	*x = &n1;
	*y = &n2;
	
	cout << "Please Enter the first value:";
	cin >> n1;
	cout <<"\nEnter second value:";
	cin >> n2;
	

	
	cout << dosomething(*x,*y);
	

}

int dosomething (int *x,int *y)
{

	int temp;
	
	temp = *x;
	
	*x = *y * 10;
	
	*y = temp * 10;
	
	return *x + *y;
}

Well, this one is actually rather straight forward. For one, look at line 7 and line 28- they don't match (this is one of those cases where int * x, int *x, and int* x can get confusing). Second, on line 23, what are you passing to dosomething? You're not passing the pointers, but what they're pointing to. But your function call expects pointers.
hey ispil thanks for your reply. Line 7 and line 28 looks to me like i am passing the same values. I think I am confused where the pointers start to come into play. Can I not pass pointers to a function? In line 23 I thought I am passing the values of x and y to the function.
Topic archived. No new replies allowed.