Hi guys, Since my last visit here,I have made few changes in the code,implemented a tree to give users choice,seperated some codes into method and then into different files.I am now running the main program from main method file.The program works well but isn't fully functional.I was looking to display the content of my inventory into a text file from which I plan to use a sorting file to sort the contents.The thing is the method works well but only for one line and console crashes if I try to rerun the method.Also,I don't know how should I sort the contents from text file(What data structure?)
Edit(After rewriting code into write_text method)
Code:
void write_text(){
struct node *ptr=start;
int j;
FILE *ptr_file;
ptr_file =fopen("output.txt", "w");
while(ptr != NULL){
fprintf(ptr_file,"\n%d.\t%s %s %d %s \n", j,ptr->data.carname,ptr->data.carmodel,ptr->data.caryear,ptr->data.cartype);
ptr = ptr->next;
j++;
}
fclose(ptr_file);
}
The functions starting with f doesn't work in display method for saving linked list contents to file.
Can you please help me with this??