我是 C 的新手,试图调用一个函数,但它给我错误,我无法理解为什么
int set_price(&colour->type.name);
它返回我 expected ‘uint32_t’ 但参数是 ‘uint32_t *’ 类型。警告:传递参数“int set_price”从指针生成整数而不进行强制转换
指针在哪里
house_list *colour = NULL;
和 名称在结构中定义为
uint32_t name;
接受原始函数
int set_price(uint32_t name)
{
/do something here/
}
我做错了什么?如果在结构成员中,name 被定义为 uint32_t,并且我定义了一个指针颜色,那么我认为我需要在 colour->type 之前使用 & 并在 name 之前使用点,不是吗?
谢谢
最佳答案
set_price(&colour->type.name);
去掉 & 你会没事的
set_price(colour->type.name);
set_price
需要一个整数作为参数,而不是指向整数的指针。
我建议您阅读 a good C book .
关于c - 预期为 ‘uint32_t’ 但参数的类型为 ‘uint32_t *’,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6778384/