27.12.2015, 22:33
We already went through this:
pawn Код:
// ** INCLUDES
#include <a_samp>
// ** MAIN
main()
{
print("Loaded \"replace_underscore_with_space.amx\".");
new source[20] = "CaNDy_Boy_Mr Sr_Hey";
ReplaceUnderscoreWithSpace(source);
printf("%s", source);
}
// ** CALLBACKS
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
// ** FUNCTIONS
stock ReplaceUnderscoreWithSpace(source[])
{
for(new i = 0, j = strlen(source); i < j; i ++)
{
if(source[i] == '_')
{
source[i] = ' ';
}
}
return 1;
}
pawn Код:
// ** INCLUDES
#include <a_samp>
// ** MAIN
main()
{
print("Loaded \"replace_string.amx\".");
new source[20] = "CaNDy_Boy_Mr Sr_Hey";
ReplaceString(source, "_", " ");
printf("%s", source);
}
// ** CALLBACKS
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
// ** FUNCTIONS
stock ReplaceString(source[], const search[], const replace[], size_of = sizeof(source))
{
new search_length = strlen(search), temp, last_pos;
for(;;)
{
temp = strfind(source, search, false, last_pos);
if(temp != -1)
{
strdel(source, temp, (temp + search_length));
strins(source, replace, temp, size_of);
last_pos = (temp + search_length);
}
else
{
break;
}
}
return 1;
}