hi -

i did something similar, but i used:

char szMes[25]; //need szMes to be a string, not a char.  in this case an
array of chars.
                            //25 is just my guess for how big it can get

// later on...

switch(ID)
{
case 1:
    sprintf(szHint,"One");
    break;
case 2:
    sprintf(szHint,"Two");
    break;

}

or whatever.  i used strcpy and strcat, but i was adding things to the
string based on certain flags.  the main idea is you need char szMes[25],
which allocates a chunk for you, and not just one char.

hope this helps.  if not, then i'm out of ideas.

barret




----- Original Message -----
From: "Vyacheslav Djura" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 05, 2002 2:46 PM
Subject: [hlcoders] returning string


> Hello hlcoders,
>
>   Hi! I never used strings in C++ (I am native Delphi programmer :) ) and
now I have a problem :(
>   I need to print string to console, which depends on integer value.
>
>   I want to make such thing
>   case n of
>    1: s:='One';
>    2: s:='Two';
>    ...
>    end;
>   in a procedure. So I have such code:
>
>   char szMes;
>   ReturnTestString(szMes,m_iValue);
>   gHUD.DrawHudString( x+5, y+4, ScreenWidth, szMes, 255, 255, 0 );
>
>   and it causes HL to crash. Here is beginning of ReturnTestString
>   function:
>
> void ReturnTestString(char* &szSring,int Id)
> {
>         switch(Id){
>         case 0:
>                 sprintf(szHint,"One");
>                 break;
>         case 1:
>         ...
>         }
> }
>
> please, correct my mistake, cos I don't know C++ syntax very good :(
>
>
> --
> Vyacheslav 'Hoaxer' Djura
> Programmer
> Wrench Software                        (www.wrenchsoftware.com)
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>

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

Reply via email to