Greetings,
First of all: use code tags:
Code:
void main(){
struct mystruct *pdemo; /* You forgot the '*', typo? */
/* Also, at this point the compiler does not know about 'alloc_mystruct' it will assume it returns an int */
pdemo=alloc_mystruct(buf1,buf2,val1);
}
struct mystruct *alloc_mystruct(char *name,const char *id,int val){
struct mystruct *pMyStruct;
pMyStruct->name=(char*)malloc(sizeof(name));
pMyStruct->id=(char*)malloc(sizeof(id));
pMyStruct->val=malloc(sizeof(val));
strcpy(pMyStruct->name, name);
strcpy(pMyStruct->id, id);
pMyStruct->val=val;
return pMyStruct;
}
Second, its 'int main', not 'void main'.
Third, provides the full code, like where's buf1, buf2, val1, MyStruct defined and how?