Page 1 of 1

Passing clonename to a global function

PostPosted: Thu Apr 19, 2007 1:52 am
by jazz_e_bob
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?

PostPosted: Thu Apr 19, 2007 2:16 am
by Sgt. Sparky
textOutput.textNumber = lengthOfString("clonename");
:D
I do not know exaclty what you are trying to do, but that should work(what I typed)

PostPosted: Thu Apr 19, 2007 2:21 am
by makslane
Use a const char * as argumet of your function:

Code: Select all
int lengthOfString(const char *s)
{
...
}

PostPosted: Thu Apr 19, 2007 2:27 am
by Sgt. Sparky
oh, so that is what he was trying to do.
*face palm*

PostPosted: Thu Apr 19, 2007 4:26 am
by jazz_e_bob
Thanks guys.

:)

PostPosted: Thu Apr 19, 2007 4:32 am
by Sgt. Sparky
welcome, even though makeslane is the one with the solution! :D