Removing 'spaces' from a string - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Removing 'spaces' from a string (
/showthread.php?tid=370705)
Removing 'spaces' from a string -
Burthop - 20.08.2012
Hi guys, I am currently working on a system which is sensitive to spaces.
It reads values from a simple file like this.
Код:
Permission1
-Permission2
Permission3
ThisWouldBeTheError
If you didn't notice, the line 'ThisWouldBeTheError ' trails a space. Is there anyway I can remove that? It uses the function 'fread' to get the line, and is saved into the variable permissionHolder.
So I am guessing there could be a function like
pawn Код:
strescape(permissionHolder);
I hope it made sense to you, I am writing this at 1am in the morning :P
Re: Removing 'spaces' from a string -
detter - 21.08.2012
add this in bottom of your script
Код:
stock string_replace(string[], find, replace)
{
for(new i=0; string[i]; i++)
{
if(string[i] == find)
{
string[i] = replace;
}
}
}
this is how its used
Код:
string_replace( string ,' ' ,'') // your string ,char that needs to be replaced ,new char
Re: Removing 'spaces' from a string -
Kar - 21.08.2012
http://forum.sa-mp.com/showthread.ph...t=slice+string
the trim function