undefined symbol 'malloc' in noname.c的意思

来源:百度知道 编辑:UC知道 时间:2024/05/15 12:57:33
在tc卷面编程中的错误提示

函数名: calloc

功 能: 分配主存储器

用 法: void *calloc(size_t nelem, size_t elsize);

程序例:

#include <stdio.h>

#include <alloc.h>

int main(void)

{

char *str = NULL;

/* allocate memory for string */

str = calloc(10, sizeof(char));

/* copy "Hello" into string */

strcpy(str, "Hello");

/* display string */

printf("String is %s\n", str);

/* free memory */

free(str);

return 0;

}
函数名: free

功 能: 释放已分配的块

用 法: void free(void *ptr);

程序例:

#include <string.h>

#include <stdio.h>

#include <alloc.h>

int main(void)

{

char *str;

/* allocate memory for string */

str = malloc(10);

/* copy "