Removing 'spaces' from a string
#1

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
Reply
#2

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
Reply
#3

http://forum.sa-mp.com/showthread.ph...t=slice+string

the trim function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)