adding books to book list

2 vues (au cours des 30 derniers jours)
Mehmet Kaptan
Mehmet Kaptan le 31 Mai 2020
Commenté : Walter Roberson le 31 Mai 2020
ı have a books.txt which has book names inside like AC521 In_Praise_of_Stay-at-Home_Moms ACTION. firstly code then name and book's genre. ı want to add new book in this list how ı can make this. ı write this code
[Code,Name,Genre] = textread( 'books.txt', '%s %s %s' )
fprintf("1-ADD BOOK\n2-DELETE BOOK\n3-LIST OF BOOKS\n4-LIST OF GENRE\n5-SEARCH BOOK BY NAME\n6-PLOT HISTOGRAM\n0-EXIT\n")
n=input("Enter your Choice:")
if n==1
fid=fopen('books.txt', 'a');
  3 commentaires
Walter Roberson
Walter Roberson le 31 Mai 2020
I recommend that you hold pff opening the output file until you have obtained all the inputs from the user and validated them.
Walter Roberson
Walter Roberson le 31 Mai 2020
By the way, have a look at menu() instead of your fprintf() / input()

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 31 Mai 2020
Modifié(e) : Image Analyst le 31 Mai 2020
fprintf(fid, '%s %s %s\n', NewCode, NewName, NewGenre) ;
  4 commentaires
Mehmet Kaptan
Mehmet Kaptan le 31 Mai 2020
but ı have to add many books. ı guess ı need a loop
Walter Roberson
Walter Roberson le 31 Mai 2020
Adding a lot of books through the kind of input structure you have is going to be tedious for the user. It would be easier if you could read the information about the new books from a file.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by