[英]returning struct* from a function
I have following code 我有以下代码
struct myStruct *struct_var;
struct myStruct * select_my_struct()
{
return struct_var;
}
some_function()
{
myStruct=struct_create();//struct_create() is of return type struct myStruct *
another_function(struct_var); // line A
another_function(select_my_struct()); //line B
}
My question is: do the line A and line B does the same thing? 我的问题是: A 线和B线是否做同样的事情?
struct_var
is a pointer and select_my_struct()
returns where struct_var
points to. struct_var
是一个指针, select_my_struct()
返回struct_var
指向的位置。
So both of them are same. 所以他们俩都是一样的。
是的,它具有相同的声明,因为它需要指向mystruct数据类型的指针。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.