hello guys i made a program which inserts into 3 linked lists of struct (linked list) , inserting the name , the path and the duration as you can see in the code
, but when im running the project it stucks in this line :
fgets(n3->frame->name, 19, stdin);
how can i fix that ?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Frame
{
char *name;
unsigned int duration;
char *path; // may change to FILE*
}*p , *p1,*p2;
typedef struct Frame frame_t;
struct Link
{
frame_t *frame;
struct Link *next;
}*n , *n1 ,*n2;
typedef struct Link link_t;
struct node *insert(struct node *n3);
int main()
{
printf("1\n");
insert(n);
printf("1\n");
}
struct node *insert(struct Link *n3)
{
while (n3 != NULL)
{
n3 = n3->next;
}
if (n3 == NULL)
{
n3 = (struct node *)malloc(sizeof(struct Frame)); //gives memory to the node
fgets(n3->frame->name, 19, stdin);
n3 = (struct node *)malloc(sizeof(struct Frame)); //gives memory to the node
fgets(n3->frame->path, 100, stdin);
n3 = (struct node *)malloc(sizeof(struct Frame)); //gives memory to the node
scanf("%d",&n3->frame->duration);
}
}