0 registered members (),
1,209
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Array of strings
[Re: roBurky]
#246764
01/17/09 00:50
01/17/09 00:50
|
Joined: Jan 2008
Posts: 1,580
Blade280891
Serious User
|
Serious User
Joined: Jan 2008
Posts: 1,580
|
Erm im not sure how to do it direct but try STRING * imageGreen[2] = { "screen_nointruders.bmp", "screen_knowyourenemy.bmp" }; or STRING * imageGreen[2]; imageGreen[1] = "screen_nointruders.bmp";//Should this not be 0, or does lite-c start at 1 imageGreen = "screen_knowyourenemy.bmp";
My Avatar Randomness V2"Someone get me to the doctor, and someone call the nurse And someone buy me roses, and someone burned the church"
|
|
|
Re: Array of strings
[Re: Blade280891]
#246768
01/17/09 01:14
01/17/09 01:14
|
Joined: Nov 2008
Posts: 8
roBurky
OP
Newbie
|
OP
Newbie
Joined: Nov 2008
Posts: 8
|
Thanks for responding, Blade. If I try your second suggestion, then the first line goes through ok, but the second and third lines get another error message. Can not convert 'ARRAY' to 'struct STRING'
|
|
|
Re: Array of strings
[Re: badapple]
#246779
01/17/09 05:51
01/17/09 05:51
|
Joined: Jul 2005
Posts: 1,002 Trier, Deutschland
Nowherebrain
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
|
I thought you would use....
willkomen.pstring[0] = "_words and numbers and such 1!!"; willkomen.pstring[1]; willkomen.pstring[2]; willkomen.pstring[3]; willkomen.pstring[4];
that would be 5 strings. and my_text.pstring would be wrong...you would use the name of the TEXT* object/element
Last edited by Nowherebrain; 01/17/09 05:55.
|
|
|
Re: Array of strings
[Re: Nowherebrain]
#246833
01/17/09 14:43
01/17/09 14:43
|
Joined: Nov 2008
Posts: 8
roBurky
OP
Newbie
|
OP
Newbie
Joined: Nov 2008
Posts: 8
|
Thank you, I've made progress due to your replies, badapple and Nowherebrain. Looking at the command help for pstring gave an example of an array of strings, which I've used to create the array successfully (I think).
TEXT tScreenGreen =
{
string ("screen_knowyourenemy.bmp", "screen_nointruders.bmp");
}
And then through a lot more trial and error, figured out that I needed to use this to access it: (tScreenGreen.pstring)[0] So thanks everyone! I'm back on track.
|
|
|
Re: Array of strings
[Re: TechMuc]
#248023
01/23/09 22:46
01/23/09 22:46
|
Joined: Jul 2004
Posts: 1,710
MMike
Serious User
|
Serious User
Joined: Jul 2004
Posts: 1,710
|
|
|
|
Re: Array of strings
[Re: MMike]
#248034
01/23/09 23:52
01/23/09 23:52
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! Thanks for the information TechMuc. That might be the solution to my post. I think that there is a syntax error in the first line that was presented by roBurky STRING imageGreen[2] = { "screen_nointruders.bmp", "screen_knowyourenemy.bmp" }; should have been STRING imageGreen[2] = ( "screen_nointruders.bmp", "screen_knowyourenemy.bmp" ); Ottawa
|
|
|
Re: Array of strings
[Re: Ottawa]
#253722
02/26/09 10:58
02/26/09 10:58
|
Joined: Feb 2009
Posts: 33 Germany, Hamburg
Vorick
Newbie
|
Newbie
Joined: Feb 2009
Posts: 33
Germany, Hamburg
|
Sorry to dig up a post that's been inactive for a month. I hope this doesn't count as resurrecting dead threads. I'm currently working with string arrays myself in order to generate an onscreen-log for the server-side of my game. Although techmuc's post provided me with the solution to my problem, there seems to be a typo in it and I just want to spare anyone else finding this topic the headache. malloc uses only one parameter and therefore you have to multiply the number of elements with sizeof(STRING*). The code below should be the correct one and is working in my scenario. STRING** tst;
tst = malloc(sizeof(STRING*) * number of elements);
for(int i=0;i<number of elements;i++)
tst[i]=str_create("#number of characters");
//now you can access the string array like this:
str_cpy(tst[0],"hallo");
Last edited by Vorick; 02/26/09 10:59.
A8.10 Commercial
|
|
|
|