开发者

Defining an abstract type in C

开发者 https://www.devze.com 2023-01-17 08:53 出处:网络
Is it possible to have the array subscript before the variable name in declaration? For example, is it possible to have

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号