gpt4 book ai didi

allocArray 的类型冲突

转载 作者:行者123 更新时间:2023-11-30 16:03:26 25 4
gpt4 key购买 nike

伙计们,我正在尝试用 c 语言编译我的程序,但我收到此错误(allocArray 的类型冲突)?

这是我的代码:

#include <stdio.h>
#include <stdlib.h>
int number(int);
char *allocArray(int);

int main ()
{
printf("Enter a number: ");
int userNumber;
scanf("%d", &userNumber);
int m= number(userNumber);
printf("\nThe number is %d", m);
printf("\n");

printf("*****************************************************\n");
printf("The array is %s", alloArray(5));

}

int number(int n)
{

int num = n;

return num;
}

char *alloArray(int num)
{
char *addr;
addr = (char *) malloc(num);
//addr = char[num];
return addr;
}

最佳答案

您将 allocArray 拼错为 alloArray(事实上,两次)。

关于allocArray 的类型冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4127279/

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