Page 1 of 1

How do you assign strings?

PostPosted: Fri Nov 04, 2011 5:29 pm
by SuperSonic
I know this is a really stupid question, but I've never had to assign strings until now :roll:

I have added a string array variable in my global code and I just want to know how to assign a value to it because when I do this:
Code: Select all
String[1] = "blablabla";

I get an error saying:
error message wrote:Illegal assignment operation

Could someone please help me? :)

Re: How do you assign strings?

PostPosted: Fri Nov 04, 2011 5:48 pm
by SuperSonic
Never mind. I found the problem :D

Re: How do you assign strings?

PostPosted: Fri Nov 04, 2011 8:22 pm
by lcl
I think I'd still explain you what was the problem, so you can understand it fully. :)
You had:
Code: Select all
String[1]

which is a string of 1 character, so your blablabla won't fit in it xD
You would've needed (at least):
Code: Select all
String[9];

Note that GE has limit of 255 characters in a string.

Also, for setting a string you need to use strcpy() or sprintf(). :)

Re: How do you assign strings?

PostPosted: Fri Nov 04, 2011 8:59 pm
by SuperSonic
lcl wrote:Also, for setting a string you need to use strcpy() or sprintf()

Yeah, I figured that out :roll:
lcl wrote:which is a string of 1 character, so your blablabla won't fit in it xD

Yeah, haha :lol: