Raised This Month: $ Target: $400
 0% 

[HELP] Assign constants to an arrays of variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-11-2014 , 06:12   [HELP] Assign constants to an arrays of variable
Reply With Quote #1

Hey, guys! I don't know if my termins are right, but I guess so. Now on the problem. Let's say I have three constants - const1, const2 and const3. And I want to assing them to arrays in one variable. Like the first array of the var should be equal to the first const, the second array to be equal to second const and etc. I don't even know if that's possible, but if it is, I would want to know the way. Let me show you what I've tried:
PHP Code:
new const1[][] = {"""Something1"}
new 
const2[][] = {"""Something2"}
new 
const3[][] = {"""Something3"}

//...//
new Consts[3]
Consts[0] = const1
Consts
[1] = const2
Consts
[2] = const3 
But I get error - Must be assigned to an array. Only when I add an index to the const, like a num from it, it's all right. I know, that it should be equal to something, when it's variable, but I want the variable's array to be equal just to the const name. Tried with defines, but it's too far hardcoding - maany errors. Any ideas?
__________________

Last edited by Flick3rR; 06-11-2014 at 06:56.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-11-2014 , 06:28   Re: [HELP] Assing constants to an arrays of variable
Reply With Quote #2

So you are trying to use pointers? If you provided information about what you are actually trying to do, a better solution could probably be found (aka The XY Problem).
__________________
fysiks is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-11-2014 , 06:40   Re: [HELP] Assing constants to an arrays of variable
Reply With Quote #3

Hmm, thread title needs a little repair.
WildCard65 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-11-2014 , 06:59   Re: [HELP] Assign constants to an arrays of variable
Reply With Quote #4

The whole story is that I want to use the different constants as one variable with arrays in a loop, where to loop between the arrays of variable. I say again, maybe this what I call 'array' is not the same as what it means, but i mean the [32] after the var for example (think these were vector cells, but noe pretty sure). So, I need to use different const names in a loop, which are in one variable, and Variable[0] will be const1, Varriable[1] will be const2, etc. I'm not sure if this is possible.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-11-2014 , 07:17   Re: [HELP] Assign constants to an arrays of variable
Reply With Quote #5

If this is true, you have to use a string function in order to change strings around (like strcopy)
WildCard65 is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 06-11-2014 , 08:24   Re: [HELP] Assign constants to an arrays of variable
Reply With Quote #6

To beging with, you are trying to assign 2D array (const) to 1D array(Consts)
PHP Code:
 copy(Constscharsmax(Consts), const1[0]); 
I have no idea what are you trying to achieve though.
SpeeDeeR is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-11-2014 , 09:03   Re: [HELP] Assign constants to an arrays of variable
Reply With Quote #7

Okay. Let me explain more. I want to put three consts into one variable with three vector cells. Maybe if I make the variable with two arrays (I mean two [][]) and put in the frist 3 vector cells, because the consts are three, and in the second vector cells I will have to put the size of each const. But it's only one array (the second []), when I have to put different sizes of consts for the three different consts in the first array (which is [3]). Like when the first array is [0], the second to be [sizeof const1], when the first array is [1], the second to be [sizeof const2]. Don't know how to explain it, but I want to get the different const name when the vector cell of the variable is different. For the different cell to result a different const. Again, don't know if this imaginated method is possible.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 06-11-2014 , 09:59   Re: [HELP] Assing constants to an arrays of variable
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
The XY Problem
__________________
hleV is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-11-2014 , 10:02   Re: [HELP] Assign constants to an arrays of variable
Reply With Quote #9

Don't know snything 'bout that XY problem. Can someone explain, or it is still unsolved?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-11-2014 , 14:58   Re: [HELP] Assign constants to an arrays of variable
Reply With Quote #10

Quote:
Originally Posted by Flick3rR View Post
Don't know snything 'bout that XY problem. Can someone explain, or it is still unsolved?
http://mywiki.wooledge.org/XyProblem
__________________
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode