Thread: Coloring with for statements

  1. #16
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    GC you got those errors because you used a namespace and then didn't use

    std::cout

    you used

    cout.


    Heres the program i wrote to demonstrate how to use the header. i tried to post it yesterday to help answer inq's question bout namespace but it wouldn't let me:

    Code:
    /*	Steven Billington
    *	October 30, 2002
    *	ColorTest.cpp
    *
    *   petter-color.h allows you to use colors with cout in win32
    *   Copyright (c) 2002
    *
    *   petter-color.h made by Petter ("Sang-drax") Strandmark
    */
    
    /*	Preprocessor Directives*/
    #include <iostream.h>
    #include <windows.h>
    #include <petter-color.h>
    #include <stdlib.h>
    
    /*	Namespaces needed for correct functioning*/
    using namespace std;
    using namespace Petter;
    
    
    int main()
    {
    	/*	Examples of colored text*/
    	std::cout<<RED<<"This text is red.\n";
    	std::cout<<BLUE<<"This text is blue.\n";
    	std::cout<<WHITE<<"This text is white.\n";
    	std::cout<<GREEN<<"This text is green.\n";
    	std::cout<<NORMAL<<"\n";
    
    	system("pause");
    
    	/*	Good practice to return value for main*/
    	return 0;
    
    }

  2. #17
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    I did something similar which might be easier for longer programs, I just dropped the "using namespace Petter" part and wrote:
    Code:
    cout<<Petter::BLUE<<"This text is blue"<<endl;
    cout<<Petter::RED<<"This text is red"<<endl;
    BTW, thanks Sang-drax for a great and useful header!

  3. #18
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Now I know what the error is.

    My color header works with the ostream class.
    However, there is two different ostream in most C++ compilers. One is called std::ostream, located in <iostream> and is the class you should use. The other one is just called ostream, located in <iostream.h> and is deprecated.

    My color header only works with std::ostream.

    (edit) Looks like R-o-D said pretty much the same thing...(/edit)
    Last edited by Sang-drax; 10-31-2002 at 01:31 PM.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #19
    Registered User GreenCherry's Avatar
    Join Date
    Mar 2002
    Posts
    65
    ok, Ill try that later, and fill you in. BTW im using MSVS 6.0
    I have a rabbit in my pants! Please be happy for me.

  5. #20
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Originally posted by GreenCherry
    ok, Ill try that later, and fill you in. BTW im using MSVS 6.0
    The compiler shouldn't matter with this header.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 07-10-2006, 12:05 AM
  2. Textring Problem: Bad coloring
    By Sentaku senshi in forum Game Programming
    Replies: 2
    Last Post: 10-18-2002, 03:28 PM
  3. window coloring
    By Labelizm in forum Windows Programming
    Replies: 4
    Last Post: 07-22-2002, 07:06 PM
  4. Coloring in the background of shape rectangle...
    By Nutshell in forum C Programming
    Replies: 6
    Last Post: 03-09-2002, 08:09 AM
  5. C editor (syntax coloring)
    By dbaryl in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 11-29-2001, 05:27 PM