adding books to book list
2 views (last 30 days)
Show older comments
ı 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 Comments
Walter Roberson
on 31 May 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
on 31 May 2020
By the way, have a look at menu() instead of your fprintf() / input()
Answers (1)
Walter Roberson
on 31 May 2020
Edited: Image Analyst
on 31 May 2020
fprintf(fid, '%s %s %s\n', NewCode, NewName, NewGenre) ;
4 Comments
Walter Roberson
on 31 May 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.
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!