two easy methods:
1- the header file: <graphics.h>
OR
2- the OLD turbo C for "C Language" compiler, you can use in it direct calls to manipulate with the user like setcolor() .. gotoxy() .. and even more ..
*I think the OLD Borland can do that too ...(like Borland 5 but I'm not sure if there u need to include a special header file ..)
I am using Dev C++
Please explain the code as well, I m novice programmer
That is OK, it may be best you dont try and understand the "nuts and bolts" of this code then, however I have tried to explain it for you with the following piece of code with comments.
Regards
Code:
#include <iostream>
#include <windows.h>
#define black 0
#define dark_blue 1
#define green 2
#define cyan 3
#define red 4
#define dark_purple 5
#define brown 6
#define gray 7
#define dark_gray 8
#define blue 9
#define neon_green 10
#define light_blue 11
#define light_red 12
#define purple 13
#define yellow 14
#define white 15
//actual function to set color
void color(int color)
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); // A handle to the console screen buffer.
SetConsoleTextAttribute(hCon,color); // A function to set the attributes of
} // characters written to the console screen buffer
int main()
{
color(4); // Calling color function with parameter of 4 = RED
std::cout << "This text will be RED! " << "\n"; // Use standard output to screen, now text is RED
color(2); // Calling color function with parameter of 2 = GREEN
std::cout << "This text will be GREEN! " << "\n"; // Use standard output to screen, now text is GREEN
std::cin.get(); // Used to keep console window open.
return 0;
}
Windows.h is probably one of the most common includes in all of the C/C++ programming language.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site. Modifications Required For VB6 Apps To Work On Vista
Bookmarks