Hello i need to fscanf this file and put it on a linked list here is the file below:
so far here is what i did :
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct p{
char post[2];
char name[20];
char club[20];
}p;
int main()
{
FILE *fp;
fp = fopen("player.txt","r");
char next_word[20];
while (fscanf(fp, "%s", next_word) != EOF)
{
p *n = malloc(sizeof(p));
if (n == NULL)
{
return 0;
}
strcpy(n->post, next_word);
printf("%s",n->post);
return 0;
}
}
the issue here is that it only scanf the Gk and not the other things that i want to put on the list anyone know can i solve this ?