fork download
  1.  
  2. // heart.c
  3. // Prints a red ASCII heart with "navya love lavesh" centered inside.
  4. // Works on UNIX terminals. On Windows 10+ it will try to enable ANSI support.
  5.  
  6. #include <stdio.h>
  7.  
  8. #ifdef _WIN32
  9. #include <windows.h>
  10. void enable_vt_mode(void) {
  11. HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  12. if (hOut == INVALID_HANDLE_VALUE) return;
  13. DWORD dwMode = 0;
  14. if (!GetConsoleMode(hOut, &dwMode)) return;
  15. dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
  16. SetConsoleMode(hOut, dwMode);
  17. }
  18. #else
  19. void enable_vt_mode(void) { /* nothing needed on most UNIX-like terminals */ }
  20. #endif
  21.  
  22. int main(void) {
  23. enable_vt_mode();
  24.  
  25. // ANSI color codes
  26. const char *RED = "\x1b[31m";
  27. const char *RESET = "\x1b[0m";
  28.  
  29. // We'll print an ASCII heart; line that contains the message centers it.
  30. // Keep the message exactly as requested:
  31. const char *msg = "navya love lavesh";
  32.  
  33. printf("\n");
  34. printf("%s *** *** %s\n", RED, RESET);
  35. printf("%s ******* ******* %s\n", RED, RESET);
  36. printf("%s ********* ********* %s\n", RED, RESET);
  37. printf("%s ************************ %s\n", RED, RESET);
  38. printf("%s ************************** %s\n", RED, RESET);
  39.  
  40. // Row with message centered inside the heart
  41. // We'll place the message padded inside the red area
  42. printf("%s************************%s %s %s************************%s\n",
  43. RED, RESET, msg, RED, RESET);
  44.  
  45. printf("%s ************************%s\n", RED, RESET);
  46. printf("%s ********************** %s\n", RED, RESET);
  47. printf("%s ******************** %s\n", RED, RESET);
  48. printf("%s **************** %s\n", RED, RESET);
  49. printf("%s ************ %s\n", RED, RESET);
  50. printf("\n");
  51.  
  52. return 0;
  53. }
  54.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
      ***       ***      
    *******   *******    
   ********* *********   
  ************************  
 ************************** 
************************ navya love lavesh ************************
 ************************
  **********************  
   ********************   
    ****************    
      ************