gpt4 book ai didi

动态的 C 函数和结构

转载 作者:太空狗 更新时间:2023-10-29 15:24:12 25 4
gpt4 key购买 nike

我想知道是否可以像在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com