I want to print name and age of person in program
Code:
#include <stdio.h>#include <stdlib.h>
#include <string.h>
typedef struct Person
{
char Name[20];
int Age;
int *next;
}List;
int main()
{
List *head = NULL;
head = (List*)malloc(sizeof(List));
head->Age = 20;
strcpy(head->Name,"Abhi\n");
head->next = NULL;
while(!head)
{
printf(" %d ",head->Age);
printf(" %s ",head->Name);
head = head->next;
};
free(head);
return(0);
}
warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
head = head->next;
^
What's wrong in the code ?