| | |
Would like to add color to my program.
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 4
Reputation:
Solved Threads: 0
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.
}
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.
}
•
•
Join Date: Nov 2008
Posts: 19
Reputation:
Solved Threads: 6
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
http://gpwiki.org/forums/viewtopic.php?t=2884
hmm well i havnt done it in awhile but when i did i used this function
if you loop through the colors like
C Syntax (Toggle Plain Text)
void setcolor(unsigned short color) { HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hCon,color); }
C Syntax (Toggle Plain Text)
for(int i =0i<=255;i++) { setcolor(i); cout << i; }
Last edited by twek; Nov 5th, 2008 at 4:44 am.
for(;;){twek();}
![]() |
Similar Threads
- Math Tutoring Program (C++)
- Computer Architecture Reference (Computer Science)
- help with hangman program (Java)
- VB - How to open an Excel Doc w/ existing data & add data in specific cells? (VB.NET)
- Help with Java program writing (Java)
- Help with a problem with C++ program (C++)
- We have lost most of the program associations. (Windows Software)
- C++ efficiency program (C++)
- Need help writing a program (C++)
Other Threads in the C Forum
- Previous Thread: C programming
- Next Thread: Sine Series
| Thread Tools | Search this Thread |
#include * append array arrays asterisks binarysearch calculate changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv feet fflush fgets file fork forloop framework function getlasterror givemetehcodez grade gtkwinlinux hacking histogram inches include incrementoperators input intmain() iso kernel keyboard km license linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number oddnumber odf opendocumentformat opensource overwrite owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv recvblocked research reversing scanf scripting segmentationfault sequential socket socketprograming standard string structures systemcall testing threads turboc unix user variable voidmain() wab whythiscodecausesegmentationfault windowsapi





