宣言的宏 [英] Macro for declaration

查看:87
本文介绍了宣言的宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我是否真的有可能在没有明确输入的情况下声明100

变量??

请考虑以下事项:


int var1 = 0;

int var2 = 0;

...........

............

int var99 = 0;

int var100 = 0;


工作是写一个短的使用时的宏,在代码中粘贴上面的

声明。

Can anyone tell me if it is really possible to do declare 100
variables without "explicitly typing it"?
Consider the following:

int var1=0;
int var2=0;
...........
............
int var99=0;
int var100=0;

The job is to write a "short" macro which when used, pastes the above
declarations in the code.

推荐答案

你会的使用阵列可能会更好。


Rachael
You''ll probably be better off using an array.

Rachael


2月26日下午3:00,SRR < SRRajesh1 ... @ gmail.comwrote:
On Feb 26, 3:00 pm, "SRR" <SRRajesh1...@gmail.comwrote:

任何人都可以告诉我是否真的可以申报100

变量而不用明确地输入它?

请考虑以下事项:


int var1 = 0;

int var2 = 0;

..........

...........

int var99 = 0;

int var100 = 0;


工作是写一个短的使用宏时,在代码中粘贴上面的

声明。
Can anyone tell me if it is really possible to do declare 100
variables without "explicitly typing it"?
Consider the following:

int var1=0;
int var2=0;
..........
...........
int var99=0;
int var100=0;

The job is to write a "short" macro which when used, pastes the above
declarations in the code.



最简单的方法可能是

int var [100] = {0};

你声明一个数组而不是100个变量。每当你使用你的100个变量中的一个时,你就可以使用额外的一对

的方括号来获得相同的效果;并且你得到了额外的

的好处,能够对变量进行循环,而不必手动将所有内容写出来。 (我不觉得你可以用'''短宏来做什么

,尽管它肯定是

可以使用一组比用手做的更短的宏来完成它。

用手做整件事。)

-

ais523

The easiest way to do it is probably
int var[100]={0};
where you declare an array rather than 100 variables. Whenever you
would use one of your 100 variables, you can just write an extra pair
of square brackets to get the same effect; and you get the added
benefit of being able to do loops over the variables without having to
write everything out by hand. (I don''t thing it''s possible to do what
you originally with a ''"short"'' macro, although it''s definitely
possible to do it with a set of macros shorter than what it would take
to do the whole thing by hand.)
--
ais523


SRR< SR ********** @ gmail.comwrote:
SRR <SR**********@gmail.comwrote:

任何人都可以告诉我,如果真的可以声明100

变量而没有明确地输入吗?
Can anyone tell me if it is really possible to do declare 100
variables without "explicitly typing it"?



我可以告诉你这个确切的问题不到两周就被问到了

前:

http://groups.google.com/ group / comp .... 0f7e5841c47817


至少粗略搜索

组通常是一个好主意在提问之前的档案。


-

C. Benson Manica |我*应该*知道我在说什么 - 如果我

cbmanica(at)gmail.com |不,我需要知道。火焰欢迎。

I can tell you that this exact question was asked less than two weeks
ago:

http://groups.google.com/group/comp....0f7e5841c47817

It''s typically a good idea to do at least a cursory search of the
group''s archives before asking a question.

--
C. Benson Manica | I *should* know what I''m talking about - if I
cbmanica(at)gmail.com | don''t, I need to know. Flames welcome.


这篇关于宣言的宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆