Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void saveToFile (book_t * head){
- FILE *fp;
- fp = fopen ("Books.csv", "w");
- if(fp==NULL)
- {
- printf("Nie można zapisac zaaktualizowanej listy.\n");
- }
- book_t *current = head;
- while (current != NULL){
- fprintf (fp, "%s;", current->title);
- fprintf (fp, "%d;", current->pages);
- fprintf (fp, "%d;", current->yearOfRelease);
- fprintf (fp, "%s;", current->date);
- fprintf (fp, "%s;", current->borrower->name);
- fprintf (fp, "%s;", current->borrower->surname);
- author_t *curr_author = current->author;
- while (curr_author != NULL){
- fprintf (fp, "%s;", curr_author->name);
- fprintf (fp, "%s", curr_author->surname);
- if (curr_author->next != NULL){
- fprintf (fp, ";");
- }
- if(!strstr(current->author->surname, "\n")){
- fprintf(fp,"\n");
- }
- curr_author = curr_author->next;
- }
- current = current->next;
- }
- fclose (fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement