I'm having a lot of problems doing this task. I have a txt with only one line of words separated by commas. I have to read this and put it in an array. So far i tried using strtok() but it just gives me errors. Here's my code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<omp.h>
int main(){
char string[5000],list[200],*token,s=", ";
int i;
FILE *lista;
lista=fopen("lista.txt","r");
i=0;
token=strtok(string,s);
strcpy(list[i],token);
while(fscanf(lista,"%s",string)!=EOF){
token=strtok(NULL,s);
strcpy(list[i],token);
i=i+1;
}
fclose(lista);
}
It gives me the" expectig char *restrict" error I'm seriously out of ideas. BTW: I'm in Linux