garfield

[COD]: Realizar a troca de letras

Jan 21st, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.50 KB | None | 0 0
  1. /*
  2.         @Função: Troca a letra de palavras.
  3.         @Créditos: [iPs]SuYaNw
  4. */
  5. stock SwitchChar(string[], ch, ch2)
  6. {
  7.     #if !defined MAX_STRING
  8.         #define MAX_STRING  (128)
  9.     #endif
  10.     new out[MAX_STRING];
  11.     for(new i, e = strlen(string); i != e; ++i)
  12.     {
  13.         string[i] = (string[i] == ch ? (out[i] = ch2) : (out[i] = string[i]));
  14.     }
  15.     return out;
  16. }
  17.  
  18.  
  19.  
  20. //Como Usar/Exemplo de uso:
  21.  
  22. public OnFilterScriptInit()
  23. {
  24.     printf("%s", SwitchChar("Olá, quero trocar 'o' por 'a'", 'o', 'a'));
  25.     return 1;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment