Thread: Quick fill question

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    11

    Quick fill question

    I can't seem to remember how to use the fill() function, or at least that is the function I think I'm wanting to use.

    I need to fill a line with x number of a certain character, say a '*' or "-" for example. What would the syntax for that be?

    It's been a long day.

    Thanks.

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Why not just make your own function for this? All it takes is a simple for loop and an output function and you're set.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    11
    Well that was my next option, as it would be very easy to do. Although I could've sworn there was something built-in that could do this for me and save me a couple lines of code and a function call.

  4. #4
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Well, if there was a fill function (which I'm definitely not aware of) you'd still have to call it, and it would still be a function.

    An optional (bad) solution would be to have a predeclared string something like so:


    Code:
      char myString[256]="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    
    // To output 10 letters:
      myString[10]='\0';
      cout << myString << endl;
    Though that is definitely the worst way you could go around doing it.
    Last edited by jverkoey; 02-25-2005 at 04:18 PM.

  5. #5
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Woop?

  6. #6
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    Nah, I like my null terminator method better


    Please excuse me, I have to go change my shirt, it's dripping with sarcasm.


    In other words: I probably should have just searched it....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. quick question (adding characters)
    By Cactus in forum C Programming
    Replies: 2
    Last Post: 09-24-2005, 03:54 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM