typedef struct { int x; int y; } Point_t;
Point_t construct_point(int x, int y); /* takes 2 integers,
returns a Point_t representing
these integers */
这个函数怎么写?
最佳答案
这真的很简单:
typedef struct
{
int x;
int y;
} Point_t;
Point_t f(int x, int y)
{
Point_t p = { x, y };
return p;
}
并且(为了预先避免可能的注释):不,这不会返回对局部变量的引用。
关于c - C语言中如何编写 "takes 2 integers, returns a Point_t representing these integers"函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29728698/