Transfering strings
#10

If the two arrays/strings has the same size, using
pawn Код:
new string1[8] = "Hello",string2[8] = "world!";
string1 = string2;
will be the fastest (and easy to use).

If you want to add some more strings behind a string you can use strcat/strcpy.
However, if more than 4-5 strcat is required to make a string, or there's non-string values to be added into the string, format will be faster.
pawn Код:
new string[128] = "Hello,",playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
strcat(string,playername);
strcat(string,"! Welcome to ");
strcat(string,servername);
strcat(string,"!");
has the similar efficiency as:
pawn Код:
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),"Hello,%s! Welcome to %s!",playername,servername);
Reply


Messages In This Thread
Transfering strings - by MP2 - 17.07.2011, 01:28
Re: Transfering strings - by =WoR=Varth - 17.07.2011, 01:32
Re: Transfering strings - by Lorenc_ - 17.07.2011, 01:37
Re: Transfering strings - by Donya - 17.07.2011, 01:48
Re: Transfering strings - by SchurmanCQC - 17.07.2011, 02:04
Re: Transfering strings - by Donya - 17.07.2011, 02:27
Re: Transfering strings - by =WoR=Varth - 17.07.2011, 02:50
Re: Transfering strings - by MP2 - 17.07.2011, 03:17
Re: Transfering strings - by Donya - 17.07.2011, 03:37
Re: Transfering strings - by leong124 - 17.07.2011, 04:29

Forum Jump:


Users browsing this thread: 1 Guest(s)