// structs with arrays

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

struct Whatever
{
    int x;
    int array1[3];
    float y;
    double array2[3];
};

void initialize(Whatever& );
void print(const Whatever&);

int main()
{
    Whatever obj1;
    initialize(obj1);
    print(obj1);

    Whatever* pW = new Whatever;
    initialize(*pW);
    print(*pW);

    Whatever obj3 = {15,{71,73,79}, 3.14, {2.4,4.8,7.2}};
    print(obj3);
}

void initialize(Whatever& object)
{
    object.x = rand() % 100;
    for (int i = 0; i < 3; i++)
        object.array1[i] = rand() % 100;
    object.y = static_cast<float>(rand() % 100) / (rand() % 100 + 1);
    for (int i = 0; i < 3; i++)
        object.array2[i] = static_cast<double>(rand() % 100) / (rand() % 100 + 1);
}

void print(const Whatever& object)
{
    cout << setw(5) << object.x;
    for (int i = 0; i < 3; i++)
        cout << setw(5) << object.array1[i];
    cout << setw(10) << object.y;
    for (int i = 0; i < 3; i++)
        cout << setw(10) << object.array2[i];
    cout << endl;
}

******  OUTPUT  ******

   41   67   34    0      2.76   1.32203  0.953846  0.108696
   81   27   61   91    2.2093   0.72973      18.2  0.037037
   15   71   73   79      3.14       2.4       4.8       7.2