Color changing

Hey so i know there is the system command line of code to change color: system("Color 1B");

But i want to change the color of only a certain paragraph or line while keeping the rest of the text the same color.

//so say i have this colored green
"hello world"

//but i want this to be red without changing the color of the first line
"hello earth"

HOW DO I DO THAT?
Last edited on
Check out this code, and modify it for your project. I hope you like it.

------------------------------

// Purpose: Start from scratch and teach how to make color text games

#include<iostream>
#include<windows.h> // for text color

using namespace std;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

int main(void) {

int countRow = 0;
int countCol = 0;
for( ; countRow<16; countRow++) {
for( ; countCol<16; countCol++) {
int tempColor = (countRow * 16) + countCol;
SetConsoleTextAttribute(hConsole, tempColor);
cout << tempColor << " ";
}
countCol = 0;
cout << endl;
}

SetConsoleTextAttribute(hConsole, 7);
system("PAUSE");

return 0;
}
Topic archived. No new replies allowed.