STRUCT – Definition And Access To Data

It works, and it does everything it has to do, but it can be improved. Of course, in a real case it is usual for each file to have to store more information than just those two example sections that we have foreseen this time. If you show us all the data on the screen and it is a lot of data, it may happen that they appear on the screen so fast that we do not have time to read them, so it would be desirable to stop when the information screen is full (for example, a pause after showing every 25 data). Of course, we can think of many more questions to ask about our data. And also, when we exit the program all the data we typed, but that is the only “almost inevitable”, because we still do not know how to handle files.


Proposed exercises:

(7.4.1) A program that asks for the name, surname and age of a person, stores them in a “struct” and then shows the three data in a same line, separated by commas.
(7.4.2) A program that asks for data from 8 people: name, day of birth, month of birth, and year of birth (which must be stored in a table of structs). Then you should repeat the following: ask for a month number and show on the screen the data of the people who turn years during that month. It will stop repeating when you type 0 as the month number.
(7.4.3) A program that is capable of storing the data of 50 people: name, address, telephone, age (using a table of structs). You must go asking for the data one by one, until a name is entered empty (press Enter without typing anything). Then a menu should appear that allows:
Show the list of all the names.
Show people of a certain age.
Show the people whose initial is the one that the user indicates.
Exit the program
(Logically, this menu must be repeated until the “exit” option is chosen).
(7.4.4) Improve the database of files (example 07.05) so that it does not allow to introduce incorrect sizes (negative numbers) or empty file names.
(7.4.5) Expand the database of files (example 07.05) to include a partial search option, in which the user indicates part of the name and shows all the files that contain that fragment.
(7.4.6) Expand the database of files (example 07.05) so that a certain data can be erased (it will be necessary to “back” all the data that there was after that, and to decrease the quantity counter of data we have).
(7.4.7) Improve the database of files (example 07.05) so that a certain data can be modified from its number (for example, data number 3). In that modification, the user should be allowed to press Enter without typing anything, to indicate that he does not want to modify a certain data, instead of replacing it with an empty string.
(7.4.8) Expand the database of files (example 07.05) so that the data can be sorted by name. To do this, you should look for information about some simple ordering method, such as the “bubble method” (in the following section you have some), and apply it to this specific case.

You may also like...

1 Response

  1. 2017

    […] Previous story STRUCT – Definition And Access To Data […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!