我写了一个简单的代码(下面是它的一部分)并使用夹板检查任何警告。但斯普林特在抱怨。我可能缺少什么问题?
夹板警告
malloctest.c:24:3: Return value (type char *) ignored: gets(p)
Result returned by function call is not used. If this is intended, can cast
result to (void) to eliminate message. (Use -retvalother to inhibit warning)
代码部分
p= (char*)malloc(BUFFER*sizeof(char));
if(p==NULL)
{
printf("the memory could not be allocated");
}
else
{
gets(p); //line 24
printf("the name entered is \n%s\n",p);
}
提前致谢!