My program keeps failing while loading a file that is there and returns: No such file or directory No other questions have been any help because others had different issues
incident *fileIn(incident* head){
incident *new;
new = (incident *) malloc(sizeof(incident));
if (new == NULL) {
printf("No memory has been allocated the program will exit\n");
exit(1);
}
FILE *fPointer;
fPointer = fopen("input.txt","r");
if (fPointer == NULL)
{
printf("Could not open file\n");
perror("Err");
exit(1);
}
new->next = new;
char curr_line[300];
while(fgets(curr_line, 10000, fPointer) != NULL){
new = (incident *) malloc(sizeof(incident));
char *token=strtok(curr_line,";/"); /*auth xorizei thn eisodo kathe fora pou petixenei ; h / (gia tis imerominies)*/
strcpy(new->coordinates.area,token);
token=strtok(NULL, ";/");
new->reported.day=atoi(token); /*h atoi metatrepei to string se int*/
token=strtok(NULL, ";/");
new->reported.month=atoi(token);
token=strtok(NULL, ";/");
new->reported.year=atoi(token);
token=strtok(NULL, ";");
strcpy(new->url,token);
incident* tail = head;
if (head->next == head){
head->next = new;
new->next = head;
}
tail = tail->next;
tail->next = new;
new->next = head;
}
fclose(fPointer);
}
The file is there and I also added the whole path to it but to no avail. Any help would be greatly appreciated. What can I do it's due in a few hours and I've tried every thing I could think of