c-为什么数据类型冲突



当我遇到这个问题时,我正在使用带有gcc编译器的代码块。。。错误:func32((的类型冲突;我试着更改函数的名称。但仍然不起作用

static void func32(int, int);
void main()
{
int a = 4, b = 5, c = 6;
func31(a, b);
func32(&b, &c);
printf("The Result Will Be: %dn", c - a - b);
}
static void func32(int *a, int *b)
{
int c;
c = *a;
*a = *b;
*b = c;
}

您对func32的声明表示它取两个整数(int(。

static void func32(int, int);

另一方面,您对func32的定义表明它需要两个指针(int*(。

static void func32(int *a, int *b)

这是会议记录。声明和定义应使用相同的签名。在这种情况下,参数应该是指针。

static void func32(int, int);

内存位置并不总是整数类型。定义中的签名和传递给它的值在数据类型上非常不同。因此产生了冲突。

static void func32(int *a, int *b)

解释

int a = 1:
int *p = &a; /* stores some number or sometimes alphanumeric address. you will come to notice when you simply print p
dereference it and you get a. printf("%d",*p);   */

最新更新