STRUCT – Definition And Access To Data

Proposed exercises:

(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

#include <iostream>
#include <string>
using namespace std;

structBirthBirth
{
int day;
int month;
int anyo;
};

struct dataPerson
{
string name;
initial char;
struct birthBirthday;
float note;
};

int main ()
{
dataPerson person;

persona.nombre = “Ignacio”;
persona.inicial = ‘I’;
persona.diaDeNacimiento.mes = 8;
person.note = 7.5;
cout << “The note is” << person.note;

return 0;
}

Proposed exercises:

(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.

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 !!