1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// Example program
#include <iostream>
#include <string>
struct test
{
int a = 15;
bool b = true;
float z = 1.523745789;
};
test ** function()
{
test s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20;
s2.a = 4;
test array[20] = {s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20};
test * (pArray[20])={};
for (int i=0;i<20;i++)
*(pArray+i) = (array +i);
return pArray;
}
int main()
{
test ** pArray = function();
//now testing if array was returned correctly
int testint = (*(*pArray+0)).a;
int testint2 = (*(*pArray+1)).a;
test test2 = *(*pArray+1);
std::cout << testint <<" "<< testint2 <<" " <<test2.a;
return 0;
}
|