#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct st *call(void);
int main()
{
struct st *p;
p=call();
printf("enter roll no.\n");
scanf("%d",&p->rollno);
printf("enter name\n");
scanf("%s",&p->name);
printf("enter marks\n");
scanf("%f",&p->marks);
printf("%d %s %f\n",p->rollno,p->name,p->marks);
}
struct st *call(void)
{
return malloc(sizeof(struct st));
}
Error:
str3.c: In function ‘main’: str3.c:15:14: error: dereferencing pointer to incomplete type ‘struct st’ scanf("%s",&p->name); ^ str3.c: In function ‘call’: str3.c:25:22: error: invalid application of ‘sizeof’ to incomplete type ‘struct st’ return malloc(sizeof(struct st));
scanf("%s",p->name);, don't pass address of the array/pointer, and for the other message, you have to provide the definition ofstelsesizeofcannot know its size. ` - Jean-François Fabre♦struct stdefined? You need to include the definition. Are you missing an#include? - Johnny Mopp