Thread: lost

  1. #1
    Registered User
    Join Date
    Apr 2005


    I am trying to write a loop that will display the 20 most recent calculations inputed and display them. When it loops the 21st time, I need it to kick the first value out and move everything else up. I was thinking of using a for loop to do this but I am unsure of how to start it.

  2. #2
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Phildelphia, PA
    It sounds like you want to use a circular buffer, which overwrites from the beginning when it gets full. To accomplish this, just index the array modulo the array size and make sure you don't overwrite anything you still need.

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    Why didn't you keep this with your original thread in which I suggested a circular linked list?
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The getting lost and walking in circles
    By Mario F. in forum A Brief History of
    Replies: 26
    Last Post: 05-07-2008, 09:53 AM
  2. I lost my laptop, DVD and money
    By Sang-drax in forum A Brief History of
    Replies: 21
    Last Post: 10-01-2004, 07:13 PM
  3. lost disk
    By Benzakhar in forum Linux Programming
    Replies: 7
    Last Post: 01-11-2004, 06:18 PM
  4. Lost ID number
    By ripper079 in forum C++ Programming
    Replies: 13
    Last Post: 10-04-2002, 12:51 PM
  5. API, LOST... help
    By Unregistered in forum Windows Programming
    Replies: 5
    Last Post: 03-13-2002, 03:19 PM