C语言怎么错了???????????急!急!

来源:百度知道 编辑:UC知道 时间:2024/04/29 18:04:21
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "stdlib.h"
main()
{
char *abc;
if((abc=(char *)malloc(100)==NULL)
{
printf("\n hello,my name is harry.");
exit(2);
}
printf("\n what's your name?.");;
gets(abc);
puts(abc);
free(abc);

}
在Turbo c for windows里

程序应该不会有什么问题 你没有包含内存使用头文件
#include "alloc.h"

以下是修改通过代码和修改处原错误注释:

#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"/*这里缺少个内存相关函数调用头文件*/
main()
{
char *abc;
if((abc=(char *)malloc(100)==NULL) /*这里少了个右括号*/
{
printf("\n hello,my name is harry.");
exit(2);
}
printf("\n what's your name?.");;
gets(abc);
puts(abc);
free(abc);

}

***************************************************************
若还有不清楚的请补充提问,明白请记得处理问题
***************************************************************