[Tutorial] Returning strings and arrays
#10

Really nice tutorial, well explained! +REP

Quote:
Originally Posted by B3x7K
View Post
Okay, i want to ask something..

How can i determine if this string having an underscore and i'm want to delete with strdel?
Code:
new string[] = "Hello_Hello";
str_replace("_","",string);
print(string); //Will output "HelloHello"

stock str_replace(needle[], replace[], haystack[]) //By JaTochNietDan
{
    new index = strfind(haystack, needle, true);
    
    while(index != -1)
    {
        strdel(haystack, index, index + strlen(needle));
        strins(haystack, replace, index, strlen(haystack));
        
        index = strfind(haystack, needle, true);
    }
}
About the other thing you asked, i don't get what are you asking for, your code should work already, you just need to declare
Code:
new txt[10]; //Depending on how much characters you need on this string
inside the callback
Reply


Messages In This Thread
Returning strings and arrays - by IllidanS4 - 17.02.2019, 15:09
Re: Returning strings and arrays - by Mazio - 17.02.2019, 15:11
Re: Returning strings and arrays - by SyS - 17.02.2019, 16:41
Re: Returning strings and arrays - by SymonClash - 18.02.2019, 11:39
Re: Returning strings and arrays - by Mobtiesgangsa - 18.02.2019, 22:26
Re: Returning strings and arrays - by Pottus - 19.02.2019, 21:39
Re: Returning strings and arrays - by coool - 20.02.2019, 10:17
Re: Returning strings and arrays - by K0P - 20.02.2019, 10:42
Re: Returning strings and arrays - by B3x7K - 14.09.2019, 15:35
Re: Returning strings and arrays - by Jonny - 14.09.2019, 19:21

Forum Jump:


Users browsing this thread: 1 Guest(s)