05.09.2012, 18:06
Hi guys,
Which variant is better, making one global string and using it everywhere where I need one string variable or creating local string variable in every function? In code, it'll look like this:
And of course I want to know why is it better .
Thanks.
Which variant is better, making one global string and using it everywhere where I need one string variable or creating local string variable in every function? In code, it'll look like this:
pawn Код:
//first
new
global_string[ 1024 ] // or maybe bigger
;
public OnGameModeInit( )
{
format( global_string, sizeof( global_string ), "blablabla, %d", 0 );
DoSomething( global_string );
}
public OnPlayerConnect( playerid )
{
format( global_string, sizeof( global_string ), "blablabla, %d", 0 );
DoSomething( global_string );
}
//and etc...
// second
public OnGameModeInit( )
{
new
string[ 50 ]
;
format( string, sizeof( string ), "blablabla, %d", 0 );
DoSomething( string );
}
public OnPlayerConnect( playerid )
{
new
another_string[ 50 ]
;
format( another_string, sizeof( another_string ), "blablabla, %d", 0 );
DoSomething( another_string );
}
// and etc...
Thanks.