switch() questions
#2

Quote:
Originally Posted by Blt950
Посмотреть сообщение
Hello,

I got a question about the switch() function.

Here is an example:

pawn Код:
switch(reason)
        {
            case 0:
            {
                format(string, sizeof(string), "[%d] %s has left the server. (Crashed)",playerid, pName);
            }
            case 1:
            {
                format(string, sizeof(string), "[%d] %s has left the server. (Leaving)",playerid, pName);
            }
            case 2:
            {
                format(string, sizeof(string),"[%d] %s has left the server. (Kicked/Banned)",playerid, pName);
            }
        }
Is there any reason to add a "else" inside this switch or something?
Any ideas?

Thanks
pawn Код:
switch(reason)
        {
            case 0:
            {
                format(string, sizeof(string), "[%d] %s has left the server. (Crashed)",playerid, pName);
            }
            case 1:
            {
                format(string, sizeof(string), "[%d] %s has left the server. (Leaving)",playerid, pName);
            }
            case 2:
            {
                format(string, sizeof(string),"[%d] %s has left the server. (Kicked/Banned)",playerid, pName);
            }
            default:
            {
                //The else thingy
            }
        }
Reply


Messages In This Thread
switch() questions - by Blt950 - 24.05.2011, 15:18
Re: switch() questions - by DeathOnaStick - 24.05.2011, 15:19
Re: switch() questions - by Seven_of_Nine - 24.05.2011, 15:19
Re: switch() questions - by Blt950 - 24.05.2011, 15:22

Forum Jump:


Users browsing this thread: 3 Guest(s)