Display problem

This is a discussion on Display problem within the C++ Programming forums, part of the General Programming Boards category; I have attached my cpp file, the problem is the lil section of code shown here isn't showing even when ...

  1. #1
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    Display problem

    I have attached my cpp file, the problem is the lil section of code shown here isn't showing even when called. I cannot used std::cout cause it wont' compile..

    Code:
    void openmessage ()
    {
    
    	cout <<setw(45)<<"******************************************"<<"\n";
    	cout <<setw(45)<<"*                                        *"<<"\n";
    	cout <<setw(45)<<"*            Tower of Terrors            *"<<"\n";
    	cout <<setw(45)<<"*            Steve Billington            *"<<"\n";
    	cout <<setw(45)<<"*          www.steveprog.cjb.net         *"<<"\n";
    	cout <<setw(45)<<"******************************************"<<"\n";
    	cout <<"\n\n";
    	
     
    
    }

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    You may need to flush the output buffer. Try:
    Code:
    void openmessage ()
    {
    
    	cout <<setw(45)<<"******************************************"<<endl;
    	cout <<setw(45)<<"*                                        *"<<endl;
    	cout <<setw(45)<<"*            Tower of Terrors            *"<<endl;
    	cout <<setw(45)<<"*            Steve Billington            *"<<endl;
    	cout <<setw(45)<<"*          www.steveprog.cjb.net         *"<<endl;
    	cout <<setw(45)<<"******************************************"<<endl;
    	cout <<endl<<endl;
    	
     
    
    }
    Or add:
    cout.flush();
    after the message.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    46
    mmm... this newbie was thinking that "endl" flushed the buffers. no?

  4. #4
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    ... it should work; It works for me.

  5. #5
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    yea but does it work when used in that cpp file i attached? Didn't for me

  6. #6
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    Originally posted by Ride -or- Die
    yea but does it work when used in that cpp file i attached? Didn't for me
    Yep... it worked; and it should.

  7. #7
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I know it should work, but for me it doens't show up. It compiles fine, but it skips it right to "select action" and i have no f'n idea why >_<

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    I know you said it wouldn't compile, but I would try changing it to:
    std::cout << setw(45) << "* Tower of Terrors *" << endl;

    It probably doesn't like mixing old and new. You may also need something in front of setw(), like:
    std::cout << std::setw(45) << "* Tower of Terrors *" << endl;

    And also use: <iomanip> vs <iomanip.h>

  9. #9
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    none of the above, and taking the .h out of iomanip made 6 problems turn into 23

  10. #10
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    try adding

    using namespace std;

    to the top of your program

  11. #11
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    I would put this at the beginning of your main().
    Code:
    int main()
    {
    	
    
    	std::cout <<setw(45)<<"******************************************"<<endl;
    	std::cout <<setw(45)<<"*                                        *"<<endl;
    	std::cout <<setw(45)<<"*            Tower of Terrors            *"<<endl;
    	std::cout <<setw(45)<<"*            Steve Billington            *"<<endl;
    	std::cout <<setw(45)<<"*          www.steveprog.cjb.net         *"<<endl;
    	std::cout <<setw(45)<<"******************************************"<<endl;
    	std::cout <<endl<<endl;
    
    	cout.flush();
    
    	cin.get();
    
    	return 0;
    .
    .
    .
    Once you get that working, then you can throw it into a function.

  12. #12
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    that did it swoop, thnx man.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. new problem with class
    By jrb47 in forum C++ Programming
    Replies: 0
    Last Post: 12-01-2006, 07:39 AM
  3. Display problem
    By Birdhaus in forum C++ Programming
    Replies: 1
    Last Post: 09-06-2006, 03:52 PM
  4. Replies: 2
    Last Post: 06-21-2006, 04:23 AM
  5. display problem after retrieving from text
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 01-29-2002, 05:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21