|
7 registered members (3run, miwok, AndrewAMD, Quad, TipmyPip, fairtrader, 1 invisible),
637
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: array of strings
[Re: ventilator]
#301371
12/09/09 23:29
12/09/09 23:29
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
can't you just use a TEXT pointer for storing all the strings initially
TEXT* txt_names = {
strings = 4;
string("dave", "fred", "pete", "john");
}
TEXT* txt_display = {
strings = 2;
pos_x = 200;
flags = SHOW;
}
...
(txt_display.pstring)[0] = (txt_names.pstring)[x];
...
if i knew what you were trying to do initially with the strings, could possibly give a different approach hope this helps
|
|
|
Re: array of strings
[Re: MrGuest]
#318211
04/05/10 23:35
04/05/10 23:35
|
Joined: Sep 2003
Posts: 303 Germany
Clemens
Senior Member
|
Senior Member
Joined: Sep 2003
Posts: 303
Germany
|
Lukas method looks like the most comfortable one! But it only works when the string is defined inside the function. Examples:
#include <acknex.h>
void main() {
STRING* ArrayStr[3];
ArrayStr[0] = str_create("1");
ArrayStr[1] = str_create("2");
ArrayStr[2] = str_create("3");
while (1) {
draw_text(ArrayStr[1], 10,10, vector(100,100,255));
wait(1);
}
}
Does work-> a red "2" appears on the screen!
#include <acknex.h>
STRING* ArrayStr[3];
ArrayStr[0] = str_create("1");
ArrayStr[1] = str_create("2");
ArrayStr[2] = str_create("3");
void main() {
while (1) {
draw_text(ArrayStr[1], 10,10, vector(100,100,255));
wait(1);
}
}
Doesn't work-> "Malfunction W1501 - Empty pointer in main" Reason has to be that objects/structs created by the _create command are only exist in their definition area!?! How to solve that problem?
|
|
|
|