Sorry, Origin 8 does not have much change in terms of Origin C.
You have to use malloc and free, but can wrap in a nice class, as shown below:
struct myTest {
double a;
int n;
};
class MyTestVector
{
public:
MyTestVector(int nn)
{
m_nSize = nn;
m_p = (myTest*) malloc(m_nSize * sizeof(myTest));
}
~MyTestVector()
{
free(m_p);
}
int GetSize() {return m_nSize;}
myTest* GetData() {return m_p;}
myTest* GetAt(int n) {
if(n >=0 && n < m_nSize)
return m_p[n];
return NULL;
}
private:
int m_nSize;
myTest* m_p;
};
void test(int nn = 5)
{
MyTestVector junk(nn);
for(int ii = 0; ii < junk.GetSize(); ii++)
{
myTest* pp = junk.GetAt(ii);
pp->a = ii*0.01;
pp->n = ii;
}
for(ii = 0; ii < junk.GetSize(); ii++)
{
myTest* pp = junk.GetAt(ii);
printf("val=%g, index = %d\n", pp->a, pp->n);
}
}
CP