adding books to book list

2 visualizaciones (últimos 30 días)
Mehmet Kaptan
Mehmet Kaptan el 31 de Mayo de 2020
Comentada: Walter Roberson el 31 de Mayo de 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 comentarios
Walter Roberson
Walter Roberson el 31 de Mayo de 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 el 31 de Mayo de 2020
By the way, have a look at menu() instead of your fprintf() / input()

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 31 de Mayo de 2020
Editada: Image Analyst el 31 de Mayo de 2020
fprintf(fid, '%s %s %s\n', NewCode, NewName, NewGenre) ;
  4 comentarios
Mehmet Kaptan
Mehmet Kaptan el 31 de Mayo de 2020
but ı have to add many books. ı guess ı need a loop
Walter Roberson
Walter Roberson el 31 de Mayo de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by