Advertisement
PiXLFAIL

Untitled

Oct 5th, 2023
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // Definiere Escape-Zeichen für Farben
  5. #define RESET "\033[0m"
  6. #define BLACK "\033[30m" /* Schwarz */
  7. #define RED "\033[31m" /* Rot */
  8. #define GREEN "\033[32m" /* Grün */
  9. #define YELLOW "\033[33m" /* Gelb */
  10. #define BLUE "\033[34m" /* Blau */
  11. #define MAGENTA "\033[35m" /* Magenta */
  12. #define CYAN "\033[36m" /* Cyan */
  13. #define WHITE "\033[37m" /* Weiß */
  14.  
  15. // Funktion zum Ausgeben eines farbigen Texts
  16. void printColorText(const string& text, const string& color) {
  17. cout << color << text << RESET << endl;
  18. }
  19.  
  20. // Funktion zum Ausgeben eines farbigen Texts ohne Zeilenumbruch
  21. void printColorTextNoNewLine(const string& text, const string& color) {
  22. cout << color << text << RESET;
  23. }
  24.  
  25. // Funktion zum Ausgeben einer Zeile in einer bestimmten Farbe
  26. void printLine(const string& color, char symbol, int length) {
  27. printColorText(string(length, symbol), color);
  28. }
  29.  
  30. int main() {
  31. printColorText("Dieser Text ist rot.", RED);
  32. printColorText("Dieser Text ist grün.", GREEN);
  33. printColorText("Dieser Text ist blau.", BLUE);
  34. printColorText("Dieser Text ist gelb.", YELLOW);
  35. printColorText("Dieser Text ist magenta.", MAGENTA);
  36. printColorText("Dieser Text ist cyan.", CYAN);
  37. printColorText("Dieser Text ist weiß.", WHITE);
  38.  
  39. printLine(RED, '-', 20);
  40. printLine(GREEN, '*', 15);
  41.  
  42. printColorTextNoNewLine("Hello", BLUE);
  43. printColorTextNoNewLine(", World!", GREEN);
  44. printColorText(" How are you?", YELLOW);
  45.  
  46. return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement