Okay, if I declare/initialize a variable, and then pass it's address to another function, is that the same as saying int* n = &i
? In other words, is the act of passing the address to another function itself CREATING a pointer? I almost wanna say to myself "yes, duh, that's a stupid question" but I just want to make sure that I am understanding this correctly.
foo(int* n) {
//do something
}
main () {
int i = 5;
foo(&i);
}
是的,您的假设是正确的,变量int * n本身具有一个唯一的地址,您可以使用&n获取该地址
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.