hi all, i've little problem about structure creating, loot at this first..
Code:
.......
struct student
{
int score;
};
struct student *creat()
{
struct student *head;
head = (struct student *)malloc (sizeof (struct student));
scanf("%d", &head->score); /* my problem is here*/
return (head);
}
int main()
{
struct student *pointer;
pointer = creat();
............
}
if i don't have a misconception, head is a pointer, it just receives an address from malloc(), and it points to an empty space created by malloc(). but here
Code:
head = (struct student *)malloc (sizeof (struct student));
scanf("%d", &head->score);
i don't understand : head->score.
did we declare a varible -score while mallocing space?
if not, how can we input a number to it(score)?