I have two code snippets basically I want a program to do color in the console but I only want it to run a certain function based on the compiler (I will use windows.h but my teacher will use conio.h because she uses Borland C++ 5.02 ) I have a idea how to do this but I'm not sure...
#include <windows.h> // WinApi header
f o r example:
if ( compiler is Borland C++ )
color = conColor
else
color = winColor
/* I know you can't assign like just but I want you to have an idea of how I want to impement it thank you in advance... */
/* Not my windows api sniplet I think I found it here or somewhere on the internet ... */
winColor()
{
HANDLE hConsole;
int k;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// you can loop k higher to see more color choices
for(k = 1; k < 255; k++)
{
SetConsoleTextAttribute(hConsole, k);
printf("%3d %s\n", k, "I want to be nice today!");
}
SetConsoleTextAttribute(hConsole, 1);
printf ("this is ");
SetConsoleTextAttribute(hConsole, 2);
printf ("in a different printf \n");
getchar(); // wait
return 0;
}
and
#include <conio.h>
#include <stdio.h>
conColor()
{
printf("Default Color.\n");
textcolor(YELLOW);
cprintf("YELLOW");
printf("\n");
textcolor (BLUE);
cprintf (" *||*");
printf ("\n");
cprintf (" ** || **");
printf ("\n");
cprintf (" ** **");
printf ("\n");
cprintf (" ** **");
printf ("\n");
cprintf ("** **");
printf ("\n");
cprintf ("** **");
printf ("\n");
cprintf ("** **");
printf ("\n");
cprintf ("** **");
printf ("\n");
cprintf ("** **");
printf ("\n");
cprintf ("****");
printf ("\n");
getch ();
}
These are not the functions I will use but basically a function that will accept the string then 'change' the color then change the color back...(dont' need help on that just choosing the correct function for the compiler ) ...