Passing clonename to a global function

Non-platform specific questions.

Passing clonename to a global function

Postby jazz_e_bob » Thu Apr 19, 2007 1:52 am

I have a function called lengthOfString.

If you pass it a string it will return the strings length.

lengthOfString( "testing123" );
returns a 10.


However if you attempt to pass it clonename...

textOutput.textNumber = lengthOfString( clonename );

...you will get a "Cast loses const qualifier" error.

How do I pass the current actors clonename to a global function?
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby Sgt. Sparky » Thu Apr 19, 2007 2:16 am

textOutput.textNumber = lengthOfString("clonename");
:D
I do not know exaclty what you are trying to do, but that should work(what I typed)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby makslane » Thu Apr 19, 2007 2:21 am

Use a const char * as argumet of your function:

Code: Select all
int lengthOfString(const char *s)
{
...
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Sgt. Sparky » Thu Apr 19, 2007 2:27 am

oh, so that is what he was trying to do.
*face palm*
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby jazz_e_bob » Thu Apr 19, 2007 4:26 am

Thanks guys.

:)
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby Sgt. Sparky » Thu Apr 19, 2007 4:32 am

welcome, even though makeslane is the one with the solution! :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron