Thread: Dynamic Multiple Character Output

  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
    Location
    Inside my computer
    Posts
    24,654
    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,366
    Use the constructor. I'd give an example, but you bumped it after less than 20 minutes.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

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