Thread: How to store many similar data items

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    55

    How to store many similar data items

    Say i have a program that asks for client information.ie. a clients age, whether they have claimed on insurance etc. Then at the end of the program it asks if the user wants to input another form (basically repeating the program).

    What i am asking is, can i write some code that creates a new variable to store their age each time the program asks the clients age?

    I want to be able to store their age, internally, so, not storing it to a different file. I am trying to make it so that it puts each age into a new variable, so that at the end i can display only the highest age that has occured since execution of the program.

    Because i do not know how many times the user will repeat the program, i cannot simply declare a load of variables, is there anyway i can make some code that incremently creates a new variable? or that only stores the highest value?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Well you can stop shouting in the title for starters...
    A more specific thread title wouldn't go amis either (fixed)

    Use a struct to store
    - name
    - address
    - age
    - last claim date
    - anything else you need on a per customer basis

    Use an
    - array
    - linked list
    to store a variable number of these things.
    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.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    55
    okay thanks i will read up about linked lists.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. using varaibles to store data?
    By coreyt1111 in forum C++ Programming
    Replies: 6
    Last Post: 11-29-2006, 08:53 AM
  2. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM
  3. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM
  4. Do you store store one off data arrays in a class?
    By blood.angel in forum C++ Programming
    Replies: 5
    Last Post: 06-24-2002, 12:05 PM
  5. Can applications store data in DLL's ?
    By kes103 in forum C Programming
    Replies: 6
    Last Post: 06-02-2002, 06:55 PM