[Tutorial] How to use strcmp
#3

Quote:
Originally Posted by [FU]Victious
View Post
Fail. You use 256 size cells, yet you're reffering to Y_Less' topic, where he was explaining why NOT to use 256. This isn't a very good idea for new PAWN coders.
I was explaining why NOT to use it, if you'd of read it, you'd of seen.
Read the whole section, then you'll see why i used it.

Quote:

strcmp and string sizing (aimed at use of 256)
This leads back to Y_Less' topic of "Why you should not use 256" which can be found here: https://sampforum.blast.hk/showthread.php?tid=55261

By now, you should already have understanding on how strcmp works, strcmp goes through every cell of both strings to find out if each cell matches. Think about the following script;
pawn Code:

new string[256];
GetPlayerName(playerid, string, sizeof(string));

Now lets say a players name is "Bobby" (dont ask)

Theres 256 cells just to contain "Bobby" - but - strcmp still has to go through all 256 cells to see if it matches the other string. Although strcmp practically disregards the empty cells when its comparing the 2 strings, it still needs to go through the 256 cells to find out if a cell is empty. Going through all these cells for nothing seems a bit pointless, but thats what you've told the script to do, and thats what it will do. You can read more on this on the "String Manipulation" documentation at the ITB CompuPhase website - A link is available at the end of the thread.

Reply


Messages In This Thread
How to use strcmp - by Ash. - 16.12.2010, 16:49
Re: How to use strcmp - by WillyP - 16.12.2010, 16:54
Re: How to use strcmp - by Ash. - 16.12.2010, 17:00
Re: How to use strcmp - by [L3th4l] - 16.12.2010, 17:01
Re: How to use strcmp - by WillyP - 16.12.2010, 17:02
Re: How to use strcmp - by JaTochNietDan - 16.12.2010, 17:06
Re: How to use strcmp - by Ash. - 16.12.2010, 17:07
Re: How to use strcmp - by JaTochNietDan - 16.12.2010, 17:09
Re: How to use strcmp - by Ash. - 16.12.2010, 17:10
Re: How to use strcmp - by JaTochNietDan - 16.12.2010, 17:34

Forum Jump:


Users browsing this thread: 6 Guest(s)