Childe Roland wrote:
_Seem_ to have fixed it with:
------------------
        char *s;
        s = (char *)strchr( szKeyName, '#' );
        if ( s )
        {
                *s = '\0';
-----------------
Will this work, am I just missing the error, or will this cause errors
down the road??

You're missing the error. I lost the email where you showed the full function but your error is that in your functions signature you defined the szKeyName parameter as a const char*. By that you promised anyone calling your function that you wil *not* change the contents of the array that szKeyName points to.

But that is exactly what you do in that function so you are
breaking your contract with other code established with your
function signature.

So since you change the szKeyName in your function you should say
so in your function signature and declare the parameter as char*.
That will show you all the other places where code relies on the
array not getting changed by your function.

Of course the brute-force method you used works too, simply lying
about what you do in the function and casting the const away.
Althuogh in C++ you would usually use a const_cast<char*> for that
to make it obvious that you are doing something nasty here.

Florian


_______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders



Reply via email to