Reputation:
Is it possible to have the array subscript before the variable name in declaration?
For example, is it possible to have
char [10]data;
where the intended declaration is:
char data[10];
I know that this might be stretching it a bit too much, but I have the variable type defined using #define
, which I need to change from int to char[10] type.
So, could I just use #define TYPE char[10]
instead of #define TYPE int
? Or is there a better way to achieve this?
Edit:
Must I use 2 different #define statements like this?
#define TYPE char
#define SIZE [10]
and then use:
TYPE data SIZE;
Upvotes: 0
Views: 528
Reputation: 411242
You might want to consider using a typedef for this:
typedef char TYPE[10];
Upvotes: 12