Pointers

Jan 23, 2008 at 10:43pm
Hi All.

I have been reading a bit about pointers, from an article on this site as it happens. Im a tad bit confused.

How do assign a memory address to a variable? I have tried:

1
2
3
4

int test = 483;
memadd = &test;


Now the question is, can i do this and what type would i declare it as?
Last edited on Jan 23, 2008 at 10:44pm
Jan 23, 2008 at 11:18pm
Dont worry i solved it. If i read further down the page it explains it.

Correct me if im wrong but the you must declare the type of the pointer to the type of value held at that address.

1
2
3
4
5
6

int test = 483;
int mem = &test;

std::cout >> mem;
Topic archived. No new replies allowed.