#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (){
FILE *file = fopen ( "C\\input.txt", "r" );
int i=0, j=0, k=0, s=0;
char *result[10][10];
char line[100];
char *value;
char res[100][100];
for(i=0; i<=9; i++){
for(j=0;j<=9;j++){
result[i][j] = NULL;
}
}
while(!feof(file)){
fgets(line, sizeof(line), file);
strcpy(&res[s][0],line);
printf("%s \n",&res[s][0]);
s++;
value = strtok(line, ":");
result[k][0] = strdup(value);
printf("NAME: %s\n", value);
value = strtok(NULL, ",");
result[k][1] = strdup(value);
r=createAdjListNode(result[k][1]);
insert2(&hdr,r);
value = strtok(NULL, ",");
result[k][2] = strdup(value);
r=createAdjListNode(result[k][2]);
insert2(&hdr,r);
value = strtok(NULL, ",");
result[k][3] = strdup(value);
if(result[k][3]!=NULL){
r=createAdjListNode(result[k][3]);
insert2(&hdr,r);
}
if(result[k][3]==NULL){
continue;
}
k++;
}
// THIS PART IS WRONG. I WANT TO SPLIT LIST AGAIN
p=root;
char *val,*val1;
if(!strstr(&res[0][0],p->courseName)){
val=strtok(&res[0][0],":");
val1=strtok(NULL,":");
val1=strtok(val1,",");
while(val1!=NULL){
val1=strtok(val1,",");
}
}
fclose(file);
showList(&hdr);
}
My input file :
George :Math1,Germany,Math2
Elizabeth :Music,Math1
Sarah :Science,Math2
Paul :Math2,Spanish,Science
I want to create a graph with lecture names. I write %50 of code . but When I want to create an adjancecy list there is a mistake . I'm stucked.
THIS PART IS WORNG :
I store every line of input file in an array "res". I want to split again and compare my lecture names. If strstr isn't nul , i want to insert list. How can I do this ?