Answer the question
In order to leave comments, you need to log in
How does an address pass into a pointer in a function?
#include <iostream>
using namespace std;
void func(int *func_number) {
*func_number = 5;
}
int main() {
setlocale(0, "");
int main_number = 10;
func(&main_number);
cout << main_number;
system("pause");
return 0;
}
void func(int *func_number)
compiler automatically puts the address main_number
into the *func_number
?
Answer the question
In order to leave comments, you need to log in
Strange question
&main_number taking the address from the main_number variable
When the function is called, this address is passed to the func
function Inside the function, this parameter is called func_number
And what is the question? What is the difference?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question