string question
#1

So this does not work:

pawn Код:
new string[15][];
format(string[0], sizeof(string[0]), "lol");
What is the proper way to do this? So don't need something like string_1, string_2 ... string_15?

Thanks.
Reply
#2

Have you tried this?
pawn Код:
new string[15][128];
Reply
#3

Yup, still doesn't work. It displays 3 errors on one line...
Reply
#4

What are the errors?
Reply
#5

(31724) : error 001: expected token: "]", but found "-integer value-"
(31724) : warning 215: expression has no effect
(31724) : error 001: expected token: ";", but found "]"
(31724) : error 029: invalid expression, assumed zero
(31724) : fatal error 107: too many error messages on one line
Reply
#6

pawn Код:
new string[15][128];
format(string[0], 128, "lol");
That works. sizeof() seems to not work past the first level of multidimensional arrays.

Although you can just assign the string values and avoid a bunch of formats:

pawn Код:
new string[15][128] = {
    "line 1",
    "line 2",
    ...,
    "line 15"
};
Reply
#7

Quote:
Originally Posted by Whizion
Посмотреть сообщение
(31724) : error 001: expected token: "]", but found "-integer value-"
(31724) : warning 215: expression has no effect
(31724) : error 001: expected token: ";", but found "]"
(31724) : error 029: invalid expression, assumed zero
(31724) : fatal error 107: too many error messages on one line
Instead of this:
pawn Код:
new string[15][128];
    format(string[0], string[0], "lol");
It need to be like this:
pawn Код:
new string[15][128];
    format(string[0], sizeof(string[]), "lol");
    format(string[1], sizeof(string[]), "lol");
EDIT:
without the [], sizeof will print 15.
With the [], sizeof will print 128.
Reply
#8

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)