nick wrote:
the following is my programming code and compile message
why the warning message arise, have i done somethings wrong?
The error message test.c:11: warning: implicit declaration of function `malloc'
tells you: you have failed to have a declaration for the function
'malloc' in scope. This is easily fixed with
#include <stdlib.h>
No doubt you failure to #include <stdlib.h> accounts for the silly cast
on the return value from malloc()
#include<stdio. h>
typedef struct card{
int abc;
}card;
int main(){
card *d;
d = (card*) malloc(sizeof(c ard));
There is no excuse for the cast. If you put it in to stop complaints
from the compiler, you treated the symptom rather than the problem.
The normal form of this call is
d = malloc(sizeof *d);
And you should check the returned value.
return 0;
}
These and similary issues are covered in the FAQ. Before posting to a
newsgroup, check its FAQ and follow the newsgroup for several weeks (The
google.groups.c om archive makes this 'following for several weeks'
something that you can do in a much shorter time). Following these two
simple rules will keep you from asking old, tired questions that have
been answered repeatedly. Consider that your question has been asked
hundreds of times. There are two results: very few people will bother
to answer yet again the same question to which you *should* have already
found the answer by checking the FAQ, and people become angry that you
presume that we should waste our time answering a question that you
won't bother putting in any effort to find the answer on your own.