samedi 26 novembre 2022

Storing multiple strings in nested structure

I have 2 structures named Phone and Patient, respectively:

struct Phone{
    char description[4];
    char number[10];
};

struct Patient{
    int id;
    char name[15];
    struct Phone phone;
};

Now, on creating a patient's array like:

struct Patient patient = [
    {1024, "Shaggy Yanson", {"CELL","3048005191"} },
]

Upon printing the phone description value, I get the output as CELL3048005191.

NOTE: I cannot change the array

I want to know what is causing the problem. Is it the structure definition?

Aucun commentaire:

Enregistrer un commentaire