PDA

View Full Version : String into Array String


Fyske
04-10-2008, 11:13
Hello everyone,

I'm wondering if anyone know how to deal with this? I'm doing okay, but I have a huge problem to let this happen. I can't seems to be able to return a string properly, I tried to do this:

new g_myString[33];

public myFunction(id) {
new string[35];
getDaString(id, string, 34);
g_myString[id] = string;
/* only ever reports blank stuff */
client_print(id, print_console, "string is set as `%s`.^ng_myString[%d] is set as `%s`.", string, id, g_myString[id]);
}

getDaString(id, string[], len) {
/*
* do the necessary stuff, such as parse etc
*/

/* will properly report the string I'm trying to return */
client_print(id, print_console, "localvar is set as `%s`.", localvar);
formatex(string, len, localvar);
}but it doesn't seem to work.

Whenever I try to print out the string inside getDaString function, it obviously work.

When I try to print either string from myFunction it will just appear blank.

Any suggestions, please?

Arkshine
04-10-2008, 11:24
And what is the 'len' value ? You should check..

g_myString[id] = string;

Use copy() for such of situation.

Fyske
04-10-2008, 11:28
And what is the 'len' value ?

Use copy() for such of situation.
Will do, thank you, but the biggest problem, is that even the local var is BLANK...

getDaString doesn't seem to work.

Oh yeah, I forgot, len value is 34, obviously.

Let me edit my post for clarification. ;)

Arkshine
04-10-2008, 12:15
new g_myString[33]; should be new g_myString[33][max string length];