How do you assign strings?

Non-platform specific questions.

How do you assign strings?

Postby SuperSonic » Fri Nov 04, 2011 5:29 pm

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? :)
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: How do you assign strings?

Postby SuperSonic » Fri Nov 04, 2011 5:48 pm

Never mind. I found the problem :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: How do you assign strings?

Postby lcl » Fri Nov 04, 2011 8:22 pm

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(). :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: How do you assign strings?

Postby SuperSonic » Fri Nov 04, 2011 8:59 pm

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:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest