在C标记粘贴使用一个变量,增量 [英] Token pasting in c using a variable that increments
本文介绍了在C标记粘贴使用一个变量,增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一组数组: MSG1 []
MSG2 []
.... msgn []
。我需要在,而
循环中使用的值。为 MSGI []
。当我把它定义为的#define MSG(一)味精##一
并把它放在一个循环和增量 I
,将它扩展到 MSGI
?
I have a set of arrays :msg1[]
msg2[]
.... msgn[]
. And I need to use the values in a while
loop. as msgi[]
. When I define it as #define MSG(a) msg##a
and put it in a loop and increment i
, it expands it to msgi
?
推荐答案
您不能这样做的。相反,你可以创建一个新的数组,包含指向实际数组:
You can't do it that way. Instead you could create a new array, that contains pointers to the actual arrays:
int array1[...];
int array2[...];
int *all_arrays[] = { array1, array2 };
这篇关于在C标记粘贴使用一个变量,增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文