23.11.2009, 23:57
I'm trying to make a strip function that will strip leading and trailing spaces and extra spaces from within a string, it should function like this:
input:
ouput:
but the function I made is not taking out the 1 leading space before the first non space character.
function:
Anyone know whats wrong?
input:
Код:
The quick brown fox jumps over the lazy dog.
Код:
The quick brown fox jumps over the lazy dog.
function:
pawn Код:
stock strip(const s[])
{
new
j = 0,
tmp[256];
if(isnull(s))
return tmp;
for (new i = 0; (s[i] != '\0' && s[i] != '\t'); i++)
{
if ((s[i] == ' ') && (s[i+1] == ' ' || s[i+1] == '\0'))
{
}
else
{
tmp[j] = s[i];
j++;
}
}
return tmp;
}