#include <iostream>
typedef struct _elems {
    int a;
    int b;
    int c;
}elems;
static elems eArray1[]={{5,9,13}, {12,22,1}, {2,3,4},{4,3,1}};
static elems eArray2[]={{23,121,55}, {88,23,90}};

eArray1 and eArray2 can have different sizes such as 1x3, 2x3, 4x3, 5x3, etc.How to combine these ,eArray1 and eArray2, into a structure called eArray and loop and print all its sub elements in this way:
std::cout << a << b << c << std::endl;?

One way to do it is like below. I'd also put the number of elements in each array into the combined structure so that you know how big the arrays are at runtime.

typedef struct _elems {
    int a;
    int b;
    int c;
}elems;

typedef struct _elms {
    elems *e1;
    elems *e2;
    int e1Size;
    int e2Size;
} earray;

static elems eArray1[]={{5,9,13}, {12,22,1}, {2,3,4},{4,3,1}};
static elems eArray2[]={{23,121,55}, {88,23,90}};

static earray e = {eArray1, eArray2, sizeof(eArray1)/sizeof(eArray1[0]), sizeof(eArray2)/sizeof(eArray2[0])};

int main()
{
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.