dinmaic变量名 [英] dinmaic variable name

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

问题描述



让'我说我有20个变量名为a1-a20,它们都是相同的

类型(int)

我需要访问它们中的每一个并根据值执行一些

操作。

有什么方法可以在循环中访问它们并构建名称

dinamically或者我必须分别访问它们中的每一个吗?

Hi
let''s say I have 20 variables named a1-a20 which are all of the same
type (int)
I need to access each one of them and according to the value do some
operation.
Is there some way I can access them inside a loop and build there name
dinamically or do I have to access each one of them seperatly?

推荐答案

ey ******* @ gmail.com 写道:



让'我说有20个变量名为a1-a20,它们都是相同的

类型(int)

我需要访问它们中的每一个并根据值做一些

操作。

有什么方法可以在循环中访问它们并构建名称

dinamically或者我必须分别访问它们中的每一个吗?
Hi
let''s say I have 20 variables named a1-a20 which are all of the same
type (int)
I need to access each one of them and according to the value do some
operation.
Is there some way I can access them inside a loop and build there name
dinamically or do I have to access each one of them seperatly?



不,但听起来你应该存储val排在队列中。


-

Ian Collins。

No, but it sounds like you should store the values in an array.

--
Ian Collins.




Ian Collins写道:

Ian Collins wrote:
ey ******* @ gmail .com 写道:



让我们说我有20个名为a1-a20的变量全部是同样的

类型(int)

我需要访问它们中的每一个并根据值做一些

操作。

有没有什么方法可以在循环中访问它们并在那里建立名称

dinamically或者我必须分别访问它们中的每一个?
Hi
let''s say I have 20 variables named a1-a20 which are all of the same
type (int)
I need to access each one of them and according to the value do some
operation.
Is there some way I can access them inside a loop and build there name
dinamically or do I have to access each one of them seperatly?



不,但听起来你应该将值存储在数组中。


-

伊恩柯林斯。

No, but it sounds like you should store the values in an array.

--
Ian Collins.



谢谢

数组将是个好主意但是我从

数据库表中获取这些值进入一个包含很多其他字段的结构

有没有办法转换这个结构?或者其他一些方式?

Thanks
An array will be a good idea however I am getting these values from a
DB table into a struct with a lot of other fields
Is there a way to transform this struct? Or maybe some other way?


ey *** **** @gmail.com 写道:

Ian Collins写道:
Ian Collins wrote:

>> ey ******* @ gmail.com写道:
>>ey*******@gmail.com wrote:

>>>嗨
让我们说我有20个变量名为a1-a20,它们都是相同的
类型(int)
我需要访问它们中的每一个并根据值做一些
操作。
有什么方法可以在循环中访问它们并在那里建立名称
dinamically或者我必须分别访问它们中的每一个吗?
>>>Hi
let''s say I have 20 variables named a1-a20 which are all of the same
type (int)
I need to access each one of them and according to the value do some
operation.
Is there some way I can access them inside a loop and build there name
dinamically or do I have to access each one of them seperatly?


不,但它听起来就像你应该将值存储在一个数组中一样。

-
Ian Collins。


No, but it sounds like you should store the values in an array.

--
Ian Collins.




谢谢

阵列将是一个好主意但是我从
$ b获得这些值$ b DB表到一个包含很多其他字段的结构中

有没有办法转换这个结构?或者其他一些方式?



Thanks
An array will be a good idea however I am getting these values from a
DB table into a struct with a lot of other fields
Is there a way to transform this struct? Or maybe some other way?



这取决于数据库的C包装器返回的内容。那些我用b / b
为每个数据库行返回一个数组,所以你应该能够

映射到另一个数组。


你的代码填充结构吗?


-

Ian Collins。

That depends on what the C wrapper to your database returns. Those I
have used return an array for each database row, so you should be able
to map to another array.

Is your code populating the struct?

--
Ian Collins.


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

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