fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. #define MAX_BUFFER 1024
  6.  
  7.  
  8. const char * leet_from_str(const char *s)
  9. {
  10. static char buffer[MAX_BUFFER];
  11. static int MAX_INDEX = ( 'z' - 'a' ) + 1;
  12. static const char * leet_alphabet[] = {
  13. "4",
  14. "8",
  15. "(",
  16. "C-",
  17. "3",
  18. "|",
  19. "C-",
  20. "#",
  21. "1",
  22. "]",
  23. "|<",
  24. "|_",
  25. "[V]",
  26. "/V",
  27. "0",
  28. "|7",
  29. "9",
  30. "|2",
  31. "5",
  32. "7",
  33. "|_|",
  34. "\\/",
  35. "\\N",
  36. "><",
  37. "'/",
  38. "2",
  39. };
  40.  
  41. const char * chs = s;
  42. *buffer = '\0';
  43.  
  44. while( *chs != '\0' ) {
  45. int index = tolower( *chs ) - 'a';
  46.  
  47. if ( index < 0
  48. && index >= MAX_INDEX )
  49. {
  50. fprintf( stderr, "ERROR: se esperaba 'a'-'z', no: %c\n", *chs );
  51. }
  52.  
  53. strcat( buffer, leet_alphabet[ index ] );
  54. ++chs;
  55.  
  56. if ( strlen( buffer ) >= ( MAX_BUFFER - 2 ) ) {
  57. break;
  58. }
  59. }
  60.  
  61. return buffer;
  62. }
  63.  
  64.  
  65. int main(void)
  66. {
  67. printf( "%s\n", leet_from_str( "Baltasar" ));
  68. return 0;
  69. }
  70.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
84|_7454|2