So i am trying to read from a text file and put it in a variable
in the text file there is
NAME= Bame
GAME= Fame
I've heard of strsep/strtok but i'm still having issues and with this code i get Segmentation Fault 11
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main() {
char *token;
char *string;
char *tofree;
FILE *fp;
const char *file = "/tmp/test.txt";
fp = fopen(file, "r");
while(!feof(fp)) {
fgets(string, sizeof(string), fp);
token = strsep(&string, ",");
printf("%s", string);
}
fclose(fp);
exit(0);
}