malloc怎么没有呢

时间:2022-01-14 03:19:19
void main()
{
struct st
{
int a;
char b;
}*ps;

    ps=(struct st*)malloc(sizeof(struct st));
    ps->a=333;
ps->b='j';

printf("%d %c",ps->a,ps->b);

编译时:error C3861: 'malloc': identifier not found
是少了头文件吗?

9 个解决方案

#1


error C3861: 'malloc': identifier not found
error C3861: 'free': identifier not found

#2


#include<alloc.h>
或者
#include<malloc.h>

#3


当然要头文件。。。汗。。。

#4


#include <stdlib.h>

#5


你还用用了printf,也需要头文件呀。
#include <stdio.h>
#include <stdlib.h>

#6


呵呵,行了,头文件打错了,
我之前打的是#include<alloc.h>
出错 fatal error C1083: Cannot open include file: 'alloc.h': No such file or directory
换#include<malloc.h>这个就好了

呵呵~~~

#7


搞定了,就散分吧,呵呵。

#8


C这东西就是要锻炼自己的耐心,接分来了

#9


只要#include <malloc.h>就可以了。

#1


error C3861: 'malloc': identifier not found
error C3861: 'free': identifier not found

#2


#include<alloc.h>
或者
#include<malloc.h>

#3


当然要头文件。。。汗。。。

#4


#include <stdlib.h>

#5


你还用用了printf,也需要头文件呀。
#include <stdio.h>
#include <stdlib.h>

#6


呵呵,行了,头文件打错了,
我之前打的是#include<alloc.h>
出错 fatal error C1083: Cannot open include file: 'alloc.h': No such file or directory
换#include<malloc.h>这个就好了

呵呵~~~

#7


搞定了,就散分吧,呵呵。

#8


C这东西就是要锻炼自己的耐心,接分来了

#9


只要#include <malloc.h>就可以了。