I optimized a bit this code:
The syntax is correct, I?deleted the "spaces" variable because you could check the extra space by comparing the character before the text[i]. Let me know if it works the same.
EDIT: I also removed the switch case just to make the code cleaner.
EDIT 1: Optimized again a case scenario.
Final code:
Code:
for(new i = strlen(text); i >= 0; --i)
{
if(text[i] == ' ')
if(text[i-1] == ' ' || i == 0)
strdel(text, i-1, i);
}
The syntax is correct, I?deleted the "spaces" variable because you could check the extra space by comparing the character before the text[i]. Let me know if it works the same.
EDIT: I also removed the switch case just to make the code cleaner.
EDIT 1: Optimized again a case scenario.
Final code:
Code:
for(new i = strlen(text); i >= 0; --i)
{
if(text[i] == ' ')
{
if(text[i-1] == ' ')
strdel(text, i-1, i);
else if(i == 0)
strdel(text, 0, 1);
}
}
3D modeler on Blender - OOP and functional programming programmer