STRUCT – Definition And Access To Data
(7.2.1) Expand the program of Exercise 7.1.1, so that it stores data of up to 100 songs. You must have a menu that allows the options: add a new song, show the title of all the songs, find the song that contains a certain text (in the artist or in the title). Note: if it seems too complicated, in section 7.4 you have a similar example, developed from start to finish.
(7.2.2) A program that allows saving “image” data (computer files that contain photographs or any other type of graphic information). For each image you must save: name (text), width in pixels (for example 2000), height in pixels (for example, 3000), size in Kb (for example 145,6). The program must be capable of storing up to 700 images (you must notify when your capacity is full). You must allow the options: add a new tab, see all the tabs (number and name of each image), look for the card that has a certain name.
7.3. Nested structures
We can find a register that has several data, and that in turn happens that one of these data is made up of several simpler data. To do it from C ++, we would include one “struct” inside another, like this:
// Introduction to C ++, Nacho Cabanes
// Example 07.04:
// Nested records
using namespace std;
int main ()
persona.nombre = “Ignacio”;
persona.inicial = ‘I’;
persona.diaDeNacimiento.mes = 8;
person.note = 7.5;
cout << “The note is” << person.note;
(7.3.1) Expand the program of Exercise 7.2.1, so that the field ?? duration ?? is stored as minutes and seconds, using a struct? nested that contains these two fields.
[…] Previous story STRUCT – Definition And Access To Data […]