Pointers: Assign Address?

Can you assign an (arbitrary) address to a pointer?

Example:

1
2
3
4
5
6
7
8

int GetAddy()
{....
float addy = &some_variable; 
return address;
}



Can a pointer be created in another block of code which points to the address returned by GetAddy ?



nm,

just read how to pass a pointer to a function.
I guess that you can return any positive integer number (machine-sized) from a function and call it a pointer. I don't see anything that can stop you if you really want, but that pointer will be of no use, except maybe, to crash your application.

Do you have something in mind?
My intent is to alter values of variables which are beyond their local scope.
Last edited on
And why can't you use any of the standard methods? For example:

1
2
3
4
5
6
7
8
9
10
void ModifyInt(int& theInt)
{
    theInt = 5;
}

...

int myInt = 0;
ModifyInt(myInt);
...

no reason in particular, except for the fact I am a beginner and have not a good feel for standard methods, yet.
Topic archived. No new replies allowed.