簡単なコード(以下の一部)を作成し、スプリントを使用して警告をチェックしました。しかし、スプリントは不平を言っています。私が見逃している問題は何でしょうか?
スプリント警告
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);
}
前もって感謝します!