Dynamic Multiple Character Output

This is a discussion on Dynamic Multiple Character Output within the C++ Programming forums, part of the General Programming Boards category; I didn't know what to call it - so I gave the title a fancy name Anyway, I recall seeing ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155

    I honestly dont know what this feature is called

    I didn't know what to call it - so I gave the title a fancy name

    Anyway, I recall seeing a method in a c++ book where you could output a character x amount of times.

    I know you can do

    Code:
    string z (10, '*');
        cout << z << endl;
    and you'll get **********.

    Now say I don't have a string, just an int. How can i do something like
    Code:
    cout << (10, '*') << endl;
    That code segment prints out *

    How can I do that (so it'll print out 10 stars) or is a for loop required?


    Any will be greatly appreciated,

    Thanks in advance,

    Matt
    Last edited by guitarist809; 12-14-2007 at 05:38 PM.
    ~guitarist809~

  2. #2
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155
    uh yea... watching the other posts get replies. imma bump this.
    ~guitarist809~

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,915
    No, don't do that. If someone knows, they'll let you know.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    Use the constructor. I'd give an example, but you bumped it after less than 20 minutes.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    Time for an example of what happens to bumping.
    Closed.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. about wide character and multiple byte character
    By George2 in forum C Programming
    Replies: 3
    Last Post: 05-22-2006, 09:11 PM
  2. Declaring multiple character variable.
    By rajabadsha in forum C Programming
    Replies: 6
    Last Post: 05-12-2006, 01:15 PM
  3. spanish character output ansii
    By nijmegen in forum C++ Programming
    Replies: 1
    Last Post: 07-21-2002, 04:52 PM
  4. Changing the character output.
    By InFeStEd-ArCh0n in forum C++ Programming
    Replies: 7
    Last Post: 05-03-2002, 01:39 PM
  5. Slow character output...
    By |<4D4\/eR in forum C++ Programming
    Replies: 4
    Last Post: 04-16-2002, 10:10 AM

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