Error:cant convert constchar glitch

Game Editor comments and discussion.

Error:cant convert constchar glitch

Postby kyensoftware » Sun Mar 18, 2007 8:23 am

Error line 1: Incompatible types: cannot convert from const*char to ARY[256]char
CAN YOU PLEASE HELP ME I NEED THIS TO MAKE THE MAIN PART OF THE GAME: BATTLING!
Info about var:
String,save in gameVar, global
my code:
Code: Select all
robotfirstmove = "Binary Blast";

NEED HELP ASAP!
Im a good programmer with great exp in BASIC,OpenGL,C and HTML just i tink it tis a glitch.[/code]
EDIT: I fixed it, but this sucks, I have to use numbers, 0 = Binary Blast, 1 = Robo kick,etc. meh, im good at programming.
EDIT:Oh, hell here we go again! Now it wont change the text! help!
new code
Code: Select all
if (robotfirstmove = 1)
{
    text = "Binary Blast";
}












User avatar
kyensoftware
 
Posts: 198
Joined: Thu Oct 26, 2006 7:49 am
Score: 5 Give a positive score

Postby DilloDude » Sun Mar 18, 2007 9:09 am

First of all, in the if statement, change the = to ==. To assign a string, use strcpy:
Code: Select all
strcpy(text, "Binary Blast");
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

tanks

Postby kyensoftware » Mon Mar 19, 2007 4:35 am

tanks a lot (actually robot alot!!)
EDIT: WTF! it says INARY LAST?????
EDIT: hehe, well there is no uppercase, so yeah it displays white!
User avatar
kyensoftware
 
Posts: 198
Joined: Thu Oct 26, 2006 7:49 am
Score: 5 Give a positive score

Postby makslane » Mon Mar 19, 2007 1:02 pm

To compare strings, you need to use the strcmp function:

Code: Select all
if(strcmp(robotfirstmove, "binary blast") == 0) 

   //Your commands here
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron