Would like to add color to my program.

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 4
Reputation: Trades is an unknown quantity at this point 
Solved Threads: 0
Trades Trades is offline Offline
Newbie Poster

Would like to add color to my program.

 
0
  #1
Nov 4th, 2008
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.
}
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 19
Reputation: bionicseraph is an unknown quantity at this point 
Solved Threads: 6
bionicseraph bionicseraph is offline Offline
Newbie Poster

Re: Would like to add color to my program.

 
0
  #2
Nov 4th, 2008
Are you printing this out to the command line?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 19
Reputation: bionicseraph is an unknown quantity at this point 
Solved Threads: 6
bionicseraph bionicseraph is offline Offline
Newbie Poster

Re: Would like to add color to my program.

 
0
  #3
Nov 4th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: Would like to add color to my program.

 
0
  #4
Nov 5th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 8
Reputation: twek is an unknown quantity at this point 
Solved Threads: 0
twek's Avatar
twek twek is offline Offline
Newbie Poster

Re: Would like to add color to my program.

 
0
  #5
Nov 5th, 2008
hmm well i havnt done it in awhile but when i did i used this function
  1. void setcolor(unsigned short color)
  2. {
  3. HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
  4. SetConsoleTextAttribute(hCon,color);
  5. }
if you loop through the colors like
  1. for(int i =0i<=255;i++)
  2. {
  3. setcolor(i);
  4. cout << i;
  5. }
Last edited by twek; Nov 5th, 2008 at 4:44 am.
for(;;){twek();}
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: Trades is an unknown quantity at this point 
Solved Threads: 0
Trades Trades is offline Offline
Newbie Poster

Re: Would like to add color to my program.

 
0
  #6
Nov 5th, 2008
Originally Posted by bionicseraph View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: Trades is an unknown quantity at this point 
Solved Threads: 0
Trades Trades is offline Offline
Newbie Poster

Re: Would like to add color to my program.

 
0
  #7
Nov 5th, 2008
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"
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: Trades is an unknown quantity at this point 
Solved Threads: 0
Trades Trades is offline Offline
Newbie Poster

Re: Would like to add color to my program.

 
0
  #8
Nov 5th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 8
Reputation: twek is an unknown quantity at this point 
Solved Threads: 0
twek's Avatar
twek twek is offline Offline
Newbie Poster

Re: Would like to add color to my program.

 
0
  #9
Nov 5th, 2008
Originally Posted by Trades View Post
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
Attached Files
File Type: cpp prettyColors.cpp (392 Bytes, 11 views)
for(;;){twek();}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC