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;
You might want to consider using a typedef for this:
typedef char TYPE[10];
Try:
typedef char TYPE[10];
精彩评论