Like a "typedef" matrix in C

when defining new data types in C, you can do

    typedef double BYTE;

so what can later be done

BYTE length;

etc.

I would like to do something like

typedef double[30][30][10] mymatrix;

so what do i do later

mymatrix AA[10];

so I have 10 matrices of type mymatrix, and I can access them through AA [0], AA [1], etc.

Anyway, using the GNU C compiler, I get errors like

error: expected unqualified-id before '[' token

What am I doing wrong or how can I achieve my goal?

thank

+3
source share
3 answers

Follow the “announcement looks like using” Idea C:

typedef double mymatrix[30][30][10];
+3
source

The simple answer is to identify the object named and declared as you want, then stick to the typedeffront:

double mymatrix[30][30][10] ; // defines a 3-d array.


typdef double mymatrix[30][30][10] ; // defines a 3-d array type

mymatrix  matrix;
+4
source

Use this:

typedef double mymatrix[30][30][10];
+1
source

Source: https://habr.com/ru/post/1757007/


All Articles