gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > using strings

#4662 - blaow - Sun Apr 06, 2003 5:20 pm

i ran into a compilation problem when i try to use strings as variables in my code using DevKit Advance. is this normal?
what im basicly doing is an initialicing background function that will basicly do the following inside a loop
layerName[counter] = BG_COLOR256 | TEXTBG_SIZE_256x256 | (size<< SCREEN_SHIFT);

for each and every layer.. im trying to pass the names of each layer in a array of strings( layerName[]) wich contain variable names such as REG_BG0CNT, REG_BG1CNT, REG_BG2CNT..... and so on depending on the number of layers. any help is appreciated.. thnks
_________________
blaow~~

#4664 - sgeos - Sun Apr 06, 2003 5:33 pm

I'm not sure what you are trying to do, so I have two questions for you:
What are you trying to do? (Answer out loud, to yourself.)
Why? (Post this answer.)

-Brendan

#4665 - niltsair - Sun Apr 06, 2003 5:50 pm

Errrr....

I think what you want to use is a #define....
Or a Int array...

BG_COLOR256 | TEXTBG_SIZE_256x256 | (size<< SCREEN_SHIFT);
is just a bunch of #Define with some binary operators that yield a numerical value. When when it's compiled, it is transformed to an Int Value, not a string.

You might want to follow some C++ tutorial too.

#4695 - blaow - Mon Apr 07, 2003 5:31 am

i see, i was just trying to do some parsing. but nevermind.. ill stick with the int[] array idea.... thnks
_________________
blaow~~