Deleting char.
#1

Hello!

I'm having little problem with the string.

What i want to do is to check if there is let's say '' char find out the pos of it and delete it.

Код:
stock DeleteChar(text[])
{
	for(new i = 0;  text[i] != 0; i++)
	if(text[i] == ':D')text[i] = ' ';
}
Now this code works only for 1 char and i have no idea how to make it work for 2 chars.
Reply
#2

pawn Код:
stock DeleteChar(text[]) {
    new char2, text2[30];
    for(new i = 0; i < sizeof(text); i++) {
        if(strcmp(text,":",true) == 0) {
            text[i] = "*";
        }
        text2 = text[i+1];
        if(strcmp(text2,"D",true) == 0) {
            text[i+1] = "*";
            return 1;
        }
    }
    return 0;
}
Not tested, but this should remove "" smiley.
Reply
#3

TOTAL EDIT:

I found out how to make it.

Before you format message you write something like this:

Код:
strf = strfind(text, ":D", true);

if(strf != -1)
{
	strdel(text, strf, strf +2);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)