M
mangood2005
Hello
How to pass pointer to function and set it to point on particular
address? I'm trying to do this in this simple&sample code, but this
function doesn't change address pointed by pointer named counter. I
know that I can simple change this code to change value of the counter
variable, but what what I want to do for real is to set up pointer
passed as function argument to point on a class object. I hope I wrote
this quite clear.
I would be greatfull for your help
int func(int* counter){
int* pToInt=new int;
*pToInt=5;
counter=pToInt;
return 0;
}
int main(int argc, char* argv[])
{
int* test;
func(test);
coutu<<*test<<endl;
system("Pause");
return 0;
}
How to pass pointer to function and set it to point on particular
address? I'm trying to do this in this simple&sample code, but this
function doesn't change address pointed by pointer named counter. I
know that I can simple change this code to change value of the counter
variable, but what what I want to do for real is to set up pointer
passed as function argument to point on a class object. I hope I wrote
this quite clear.
I would be greatfull for your help
int func(int* counter){
int* pToInt=new int;
*pToInt=5;
counter=pToInt;
return 0;
}
int main(int argc, char* argv[])
{
int* test;
func(test);
coutu<<*test<<endl;
system("Pause");
return 0;
}