Answered Delete last char in string

Falcon!

Veteran
Messages
52
Reaction score
27
Points
803
Hello, iv been struggling for a while on how to remove the last charactor in a string, its for a keyboard im currently making in waw, anyway, i have it so if you press backspace it removes a charactor but i csnt figure it out lol, any suggestions
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,327
Reaction score
757
Points
973
Code:
removelaststring()
{
    string = "";
    for (c=0;c<level.string.size-1;c++)
        string += level.string[c];
    level.string = string;
}
Replace level.string with your current string.
 

AgreedBog381

Infinity Loader
Messages
31
Reaction score
65
Points
878
Code:
removelaststring()
{
    string = "";
    for (c=0;c<level.string.size-1;c++)
        string += level.string[c];
    level.string = string;
}
Replace level.string with your current string.
Here is a more efficient answer that should work.
Code:
removeLastChar(str)
{
    str[str.size-1] = "";
    return str;
}
 

Falcon!

Veteran
Messages
52
Reaction score
27
Points
803
thanks bro, you know i saw this kind of way with like stackoverflow and c++ but wasnt too sure, thanks again bog
 
Top