change output colour

the outpt screen in turbo c++ console is a black background with white characters,i want to to change that but i have no idea.please suggest a
remedy?

Comments

  • : the outpt screen in turbo c++ console is a black background with
    : white characters,i want to to change that but i have no idea.please
    : suggest a
    : remedy?
    :

    Do you know Google???
    Anyway, you can use the ncurses library.
  • : : the outpt screen in turbo c++ console is a black background with
    : : white characters,i want to to change that but i have no idea.please
    : : suggest a
    : : remedy?
    : :
    :
    : Do you know Google???
    : Anyway, you can use the ncurses library.
    :
    [color=Blue]Try that code:[/color]
    [code]
    #include

    int main ()
    {
    textcolor (WHITE);
    cprintf ("
    -- WHITE COLOR!");

    textcolor (YELLOW);
    cprintf ("
    -- YELLOW COLOR!");

    return 0;
    }
    [/code]
  • : : : the outpt screen in turbo c++ console is a black background with
    : : : white characters,i want to to change that but i have no idea.please
    : : : suggest a
    : : : remedy?
    : : :
    : :
    : : Do you know Google???
    : : Anyway, you can use the ncurses library.
    : :
    : [color=Blue]Try that code:[/color]
    : [code]:
    : #include
    :
    : int main ()
    : {
    : textcolor (WHITE);
    : cprintf ("
    -- WHITE COLOR!");
    :
    : textcolor (YELLOW);
    : cprintf ("
    -- YELLOW COLOR!");
    :
    : return 0;
    : }
    : [/code]:

    Thanks,well it did change the text colour but I also want to change the
    background color from black to say blue.
  • : : : : the outpt screen in turbo c++ console is a black background with
    : : : : white characters,i want to to change that but i have no idea.please
    : : : : suggest a
    : : : : remedy?
    : : : :
    : : :
    : : : Do you know Google???
    : : : Anyway, you can use the ncurses library.
    : : :
    : : [color=Blue]Try that code:[/color]
    : : [code]: :
    : : #include
    : :
    : : int main ()
    : : {
    : : textcolor (WHITE);
    : : cprintf ("
    -- WHITE COLOR!");
    : :
    : : textcolor (YELLOW);
    : : cprintf ("
    -- YELLOW COLOR!");
    : :
    : : return 0;
    : : }
    : : [/code]: :
    :
    : Thanks,well it did change the text colour but I also want to change
    : the
    : background color from black to say blue.
    :
    Well i did get a program to do just that check it out


    // This will change the background
    #include
    #include
    #include
    const int NotUsed = system( "color 1b" );
    int main()
    {
    printf("Hallo");
    getch();
    return 0;
    }

  • Dont initialize globals like that. All that is needed is this:

    [code]#include
    #include
    #include

    int main()
    {
    system ("color 1b");
    printf("Hallo");
    getch();
    return 0;
    }[/code]
    Take note that this is both compiler dependent (Not all compiliers support conio.h and windows.h) and non portable (Will not work on other operating systems but Windows)


  • system() is found in stdlib.h, you don't need to use non-standard headers at all. This code works on every C compiler in the world:

    [code]#include
    #include

    int main()
    {
    #ifdef _WIN32
    system("color 1b");
    #endif

    printf("Hello");

    getchar();
    return 0;
    }[/code]
  • : Dont initialize globals like that. All that is needed is this:
    :
    : [code]: #include
    : #include
    : #include
    :
    : int main()
    : {
    : system ("color 1b");
    : printf("Hallo");
    : getch();
    : return 0;
    : }[/code]:
    : Take note that this is both compiler dependent (Not all compiliers
    : support conio.h and windows.h) and non portable (Will not work on
    : other operating systems but Windows)
    :
    :
    : Thanks & yes it did work!its more simple than the other one

  • : system() is found in stdlib.h, you don't need to use non-standard
    : headers at all. This code works on every C compiler in the world:
    :
    : [code]: #include
    : #include
    :
    : int main()
    : {
    : #ifdef _WIN32
    : system("color 1b");
    : #endif
    :
    : printf("Hello");
    :
    : getchar();
    : return 0;
    : }[/code]:
    :
    Thanks Lundin.Your program worked as well.It shows that there are many ways to write a program in the same language to get the same result.
  • : : This code works on every C compiler in the world:

    Just a slight nitpick...

    That code may not work on all compiliers in the world. In a freestanding envirement, isnt required by the standard to be implemented do to memory restrictions. (17.4.1.3 of the C++ standard) I learned this the hard way when learning GBA programming as the compiler didnt support nor :-)

    This doesnt apply to most hosted compiliers though but just wanted to mention it.

    You are right that there is no need for non standard headers here though. Thanks for fixing it :-D


  • : : : [color=Blue]Try that code:[/color]
    : : : [code]: : :
    : : : #include
    : : :
    : : : int main ()
    : : : {
    : : : textcolor (WHITE);
    : : : [color=Red]textbackground (RED);[/color]
    : : : cprintf ("
    -- WHITE COLOR!");
    : : :
    : : : textcolor (YELLOW);
    : : : cprintf ("
    -- YELLOW COLOR!");
    : : :
    : : : return 0;
    : : : }
    : : : [/code]: : :
    : :
    : : Thanks,well it did change the text colour but I also want to change
    : : the
    : : background color from black to say blue.
    : :
    [color=Blue]
    See RED. Logically speaking the CONIO.H file should contain the other functions to manipulate the CONsole I/O and simple opening that file and looking for "textcolor" will give you "textbackground" too.
    [/color]
  • : : : : [color=Blue]Try that code:[/color]
    : : : : [code]: : : :
    : : : : #include
    : : : :
    : : : : int main ()
    : : : : {
    : : : : textcolor (WHITE);
    : : : : [color=Red]textbackground (RED);[/color]
    : : : : cprintf ("
    -- WHITE COLOR!");
    : : : :
    : : : : textcolor (YELLOW);
    : : : : cprintf ("
    -- YELLOW COLOR!");
    : : : :
    : : : : return 0;
    : : : : }
    : : : : [/code]: : : :
    : : :
    : : : Thanks,well it did change the text colour but I also want to change
    : : : the
    : : : background color from black to say blue.
    : : :
    : [color=Blue]
    : See RED. Logically speaking the CONIO.H file should contain the
    : other functions to manipulate the CONsole I/O and simple opening
    : that file and looking for "textcolor" will give you "textbackground"
    : too.
    : [/color]
    [color=green]
    Yes i know it changes The text background But i want t o change the
    colour of the whole console
    Thanks [/color]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories