I have this except from my program and would like to change the line showing the error to say red, how would I do that?

switch (choice)
{
case 1:
{
printf("\nThank you for choosing the Del Mar Store");
printf("\nThe price you entered is:      $%10.2f<<<<\n", (price));
printf("The Sales tax on that item is: $%10.2f<<<<\n", (DMPrice));
printf("Bringing your Total Sales to:  $%10.2f<<<<\n", (DMTotal));
} break;
case 2:
{
printf("\nThank you for choosing the Encinitas Store");
printf("\nThe price you entered is:      $%10.2f<<<<\n", (price));
printf("The Sales Tax on that item is: $%10.2f<<<<\n", (ENPrice));
printf("Bringing your Total Sales to:  $%10.2f<<<<\n", (ENTotal));
} break;
case 3:
{
printf("\nThank you for choosing the LaJolla Store");
printf("\nThe price you entered is:      $%10.2f<<<<\n", (price));
printf("The Sales Tax on that item is: $%10.2f<<<<\n", (LJPrice));
printf("Bringing your Total Sales to:  $%10.2f<<<<\n", (LJTotal));
} break;
default:
//Used to let user know they made an invalid Store Choice.
printf("\nI am sorry that is not a valid choice!\n\n"); This is the line I would like to change to "red" so they know that they made a mistake.
}

Recommended Answers

Are you printing this out to the command line?

Jump to Post

I did some research. This looks like it's a giant pain in the butt. Here's a helpful thread if you're hell bent on some colors
http://gpwiki.org/forums/viewtopic.php?t=2884

Jump to Post

All 8 Replies

Are you printing this out to the command line?

there are different colors associated in c
just write the color u want, above the text
for eg,
COLOR(RED);
these are all included in header file graphics.h

hmm well i havnt done it in awhile but when i did i used this function

void setcolor(unsigned short color)                
{                                                   
    HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hCon,color);
}

if you loop through the colors like

for(int i =0i<=255;i++)
{
setcolor(i);
cout << i;
}

Are you printing this out to the command line?

This is a program for school that asks the user for a dollar amount and then displays the tax and total sales for the price entered. I just want to have the different stores show up in different colors.

Tried as you suggested:

color(red);
printf("\nI am sorry that is not a valid choice!\n\n");

What I get is an error that says cannot find variable "red"

Did I say the school is using Miracle C compiler. Version 3.2, I know this might be older but it is what I have to work with.

Tried as you suggested:

color(red);
printf("\nI am sorry that is not a valid choice!\n\n");

What I get is an error that says cannot find variable "red"

did you try my suggestion?
here ill include an example for you,
please let me know if it works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.