c-不能在xcode中使用malloc.h


#if 0
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <malloc.h>
#define ColSize 2
void inputData(double*, int*, int i, int CSize);
void printdata(double*, int*, int i, int CSize);
int main(void)
{
double *RATE;
int *MIN_BALANCE;
int i, CSize;

RATE = (double*)malloc(sizeof(double)*ColSize);
MIN_BALANCE = (int*)malloc(sizeof(int)*ColSize);

i = 0;
CSize = ColSize;
inputData(RATE, MIN_BALANCE, i, CSize);
printdata(RATE, MIN_BALANCE, i, CSize);

free(RATE);
free(MIN_BALANCE);

return 0;
}
void inputData(double *RATE, int *MIN_BALANCE, int i, int CSize)
{
for (i = 0; i < CSize; i++)
{
scanf("%lf", (RATE+i));

scanf("%d", (MIN_BALANCE+i));
}
return;
}
void printdata(double *RATE, int *MIN_BALANCE, int i, int CSize)
{
for (i = 0; i < CSize; i++)
{
printf("rate: %fn", *(RATE + i));
printf("balance: %dn", *(MIN_BALANCE + i));
}
return;
}
#endif

我运行了上面的代码,但我得到了一条错误消息,即找不到"malloc.h"文件。我正在使用Mac的xcode。如何修复错误?

malloc.h是非标准的。按照C标准使用stdlib.h

相关内容

  • 没有找到相关文章

最新更新