我想知道是否可以像在 C++ 中一样为函数调用动态初始化结构:
struct point {
int x;
int y;
};
some_function(new point(x,y));
谢谢 :)
最佳答案
是的。您可以使用 compound literals , 在 C99 中引入。
some_function((struct pint) {5, 10});
关于动态的 C 函数和结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24292949/