Answers for "set console color c"

C#
0

using functions to change the console color in printf C

#include <stdio.h>
void red () {
  printf("33[1;31m");
}

void yellow {
  printf("33[1;33m");
}

void reset () {
  printf("33[0m");
}

int main () {
  red();
  printf("Hello ");
  yellow();
  printf("worldn");
  reset();
  return 0;
}
Posted by: Guest on April-06-2021
1

c# color to console color

public static ConsoleColor FromColor(Color c)
        {
            int index = (c.R > 128 | c.G > 128 | c.B > 128) ? 8 : 0; // Bright bit
            index |= (c.R > 64) ? 4 : 0; // Red bit
            index |= (c.G > 64) ? 2 : 0; // Green bit
            index |= (c.B > 64) ? 1 : 0; // Blue bit

            return (System.ConsoleColor)index;
        }
Posted by: Guest on November-14-2020

C# Answers by Framework

Browse Popular Code Answers by Language