Thread: setiosflags dont work

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    5

    setiosflags dont work

    seriously whats the deal... my output is behaving all screwy.

    Code:
        cout << "insert: :" << entry.key  << ":"
             << setiosflags(ios::right) << setw( 4) << entry.number << ":"
             << setiosflags(ios::left ) << setw(24) << entry.descript << ":\n";
        cout << resetiosflags(ios::left);
    Code:
    //outputting like this
    insert: :KT5:  14:          executive desk:
    
    //should look like this
    insert: :KT5:  14:executive desk          :
    the setiosflags(ios::left) isnt doing a thing! sorry if i sound rude. by the time i ask a question here im so frustrated i cant think stright.
    Last edited by sporkit; 04-26-2006 at 06:03 PM.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Because the ios::right flag is still set.

    Use resetiosflags with ios::right before you set ios::left, or use unsetf with ios::right
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    5
    ugh, im willing to bet i tried every other combination but the reset and then set left. i figured if you used the rest flags function it would just align it back to the defaults. i guessed wrong.

    thank you for the help and your patience jawib.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  2. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM
  3. help getting program to work
    By jlmac2001 in forum C Programming
    Replies: 2
    Last Post: 11-13-2002, 11:04 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 04:36 PM