how do i duplicate this in c++

This is a discussion on how do i duplicate this in c++ within the C++ Programming forums, part of the General Programming Boards category; Actually, my code wasn't intended to be used, I just wanted to give lilhawk a little clue (though I don't ...

  1. #16
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    Actually, my code wasn't intended to be used, I just wanted to give lilhawk a little clue (though I don't know what does exactly he want)... I'd never use that loop without a break; statement in it, otherwise it's useless.

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> They are only very rarely used as you did.
    Infinite loops are used all the time. The code was fine as an example.

  3. #18
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,436
    No. It was not. As the cin.get() at the end so very well shown it was a bad example. It was flawed. It was an infinit loop and it was badly implemented. Nice to see you find this type of code "fine as an example", Daved. Will keep that in mind.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #19
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    I left cin.get() there from another program with no loops at all, just forgot to take it out, forgive me my laxity

  5. #20
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    >> Nice to see you find this type of code "fine as an example", Daved. Will keep that in mind.

    That is so dumb. Are you even reading this thread? It reminds me of someone closing their eyes and replying to random bits of conversation as they're being pushed around.

    I can't even see why an unconditional [while(1), for(;;)] loop is poor style if you have a condition inside of it, uh, making it conditional?

  6. #21
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Mario, please stop. I find your attitude to be obnoxious, but that's irrelevant. When you make claims about the quality of someone's code, it's your responsibility to explain why and offer alternatives, as well as defend yourself in a civil manner against differing opinions. If you can't offer constructive criticism, or accept constructive criticism, be silent or you'll be silenced.
    My best code is written with the delete key.

  7. #22
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    ok theres a row a letters starting at a at from the top of the screen to the bottom...after half a second it changes to the next letter etc when it find the letter it wants it goes a space forward and the process repeats

    actually i may be able to do this with the time library and and some simple string function

    can i see some tutorials on the two if know any

  8. #23
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Oh. I think I know what you want: first print a row os 'a', when the last 'a' in that row is printed move the cursor to the right a little bit and print a row of 'b's. when the last 'b' is printed, move the cursor to the right again and print a row of 'c's. That process continues until the screen is filled with letters.

    If that is what you want, it will be fairly simple if you using Turbo C compiler because it supports the gotoxy() function, which moves the text cursor to any desired location. The program will be a bit more difficult using MS-Windows console program and a 32-bit compiler such as Dev-C++ because they do not support gotoxy(), but there are win32 api functions that will perform that task. using a *nix compiler on *nix box, use curses library to do it.

  9. #24
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    And if it doesn't support the gotoxy, you can always make one, like so -

    Code:
    void GotoXY  ( int X, int Y ) 
    { 
        COORD Cursor_Position; 
    
        Cursor_Position.X = X; 
        Cursor_Position.Y = Y; 
    
        SetConsoleCursorPosition( GetStdHandle ( STD_OUTPUT_HANDLE ), Cursor_Position ); 
    }
    Just put it in a loop or something. I put a timing class I made here. It's pretty straightforward to use.

  10. #25
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Or you could just use curses and make it cross platform for fun .

  11. #26
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,436
    Quote Originally Posted by Prelude
    Mario, please stop. I find your attitude to be obnoxious, but that's irrelevant
    I'm sure you do. And I'm sure it is as irrelevant as the need for you to say you find it obnoxious.

    Meanwhile it's a good thing we all finally understand what the OP wanted.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #27
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Do please read the tutorials on this website about for loops.
    That's the most common way to do an infinite loop in C++ or C.

  13. #28
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,660
    Then a fight broke out.
    Code:
    for( ; ; )
    { 
      // do something
    }
    This is a loop that never ends.
    Yes it goes on and on my friend.
    Some processors started running it,
    Not knowing what it was,
    and they'll continue running it forever just because.


    Now to get back on topic. I'm a bit disappointed in my fellow compatriots. We're arguing about loops. ...again.

  14. #29
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >We're arguing about loops. ...again.
    Darn, did I miss the last one?

  15. #30
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    no thats not what i want what i mean is like it keeps going down the alphabet like for a name and half second it changes the letter

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. excel (detecting duplicate data)
    By xddxogm3 in forum Tech Board
    Replies: 6
    Last Post: 01-11-2007, 09:21 PM
  2. Eliminating duplicate values from a 20x2 array
    By desipunjabi in forum C Programming
    Replies: 2
    Last Post: 10-29-2005, 09:11 PM
  3. How to duplicate a tree?
    By franziss in forum C Programming
    Replies: 2
    Last Post: 01-15-2005, 11:23 PM
  4. duplicate detection algorithm
    By Gustaff in forum C Programming
    Replies: 4
    Last Post: 01-28-2003, 11:26 AM
  5. How to check duplicate line in text file?
    By ooosawaddee3 in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2002, 05:35 PM

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