What is the difference between ptr->Name = (struct rec*)malloc(sizeof(struct rec)); from ptr->Name = malloc(sizeof(struct rec)); Why is it I'm receiving an error whenever I include (struct rec*) on malloc.
struct rec {
char *Name;
}emp[100];
int main() {
int x;
int i;
struct rec *ptr = NULL;
ptr = emp;
printf("Enter Number of Clients: ");
scanf("%d", &x);
getchar();
for(i=0; i!=x; i++)
{
printf("Enter Name: ");
//I'm receiving an error whenever I add this
ptr->Name = (struct rec*)malloc(sizeof(struct rec));
//Code below is working
ptr->Name = malloc(sizeof(struct rec));