fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. string red(string stream) {
  5. return "\033[0;31m" + stream + "\033[0m";
  6. }
  7.  
  8. string red2(const string& stream) {
  9. return "\033[0;31m" + stream + "\033[0m";
  10. }
  11.  
  12. int main() {
  13. auto str = "hello, world";
  14. cout << red(str) << endl;
  15. cout << red("hello, world") << endl;
  16. cout << red2(str) << endl;
  17. cout << red2("hello, world") << endl;
  18. }
  19.  
  20. //https://pt.stackoverflow.com/q/559382/101
Success #stdin #stdout 0.01s 5500KB
stdin
Standard input is empty
stdout
hello, world
hello, world
hello, world
hello, world