Mail Archives: djgpp/1998/07/14/22:16:00
In article <35A7CBAD DOT 5058 AT ghg DOT net DOT extra>, "R. Timm" <timmrb AT ghg DOT net DOT extra>
writes:
>Roger H. wrote:
>>
>> It is quite easy and if you are using Rhide look under the help menu for
>the
>> libc reference which lists all the functions. Anyway, you use
>> textbackground(int color) for the background color and textcolor(int
>> color) for the color of the text itself.
>>
>
>I used the following program to try and get the range of colors :
>
>*****begin
>#include <iostream.h>
>#include <conio.h>
>
>int main()
>{
> int i=0;
> for(i=0; i<16; i++)
> {
> textcolor(i);
> cout << "ABCDEFG\n";
> }
>}
>
>*****end
>
>All I got for output was 16 rows of normal white ABCDEFG. What am I
>doing wrong? This seems like it should be simple.
Are you sure that you can mix iostream and conio functions like that? I
program in C, but it seems that cout isn't going to care what settings you have
in textcolor--printf wouldn't, anyway.
If you're using conio, you might as well stick with it. You can say, for
example,
#include <conio.h>
int main(int argc, char *argv[])
{
int n_text, c;
cprintf("Hit a key to increment mode value.\n\r"
"(First textattr mode is black on black.)");
for(n_text = 0; n_text < 255; ++n_text){
textattr(n_text);
cprintf("\n\rI can't believe it's not butter! %d",n_text);
if((c=getch())=='x' || c=='q')
break;
}
textattr(7);
if(c != 'x' && c != 'q')
cprintf("\n\r(textattr 255 is white on white)");
cprintf("\n\r");
return 0;
}
/*
gcc -Wall -O example.c
*/
You could also probably use cout with ANSI escape sequences, as long as you
have ANSI.SYS installed.
--Ed (Myknees)
- Raw text -