#include <iostream>

typedef struct _test {
    int a;
    int b;
    int c;
}test; 

test sArray1[]=
{
    {10,2,3},
    {3,9,0},
    {90,56,82},
    {7,8,2}
};

test sArray2[]=
{
    {10,12,32},
    {13,99,40}
};

*//i need to initialize sArray as:*
test sArray[]={//how?. is this possible?.
    sArray1
    sArray2
};

int main(int argc, char* argv[])
{
    *//in here be able to access sArray elements.*
    return 0;
}

Good start. Your declaration/definition on line 24 should be:

test* sArray[] = {

Why, you may ask? Because naming an array by its simple name (such as sArray1 or sArray2) is actually a pointer to the array; hence, the use of the pointer type for sArray[]. IE, you have an array of pointers to arrays. Clear as mud yet? :-)

In the main, I try to print the the elements of sArray1 using sArray. It doesn't work.

#include <iostream>
typedef struct _test {
    int a;
    int b;
    int c;
}test;
test sArray1[]=
{
    {10,2,3},
    {3,9,0},
    {90,56,82},
    {7,8,2}
};
test sArray2[]=
{
    {10,12,32},
    {13,99,40}
};

test* sArray[]={
    sArray1,
    sArray2
};
int main(int argc, char* argv[])
{
    //How to iterate through elements of sArray1 ans sArray2 using sArray?.
    return 0;
}

In the main, I try to print the the elements of sArray1 using sArray. It doesn't work.

I don't see you trying to print anything anywhere.

to obtain the first element, std::cout << sArray[0]->a << std::endl; worked. what is best way to read those elements.

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.