Thread: array of strings

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    60

    array of strings

    Hey guys I am making an accounting program that uses parallel arrays.
    For example:

    I get the user to give me the account number. I then fill that number into account[i] and then I updated i. Now I want to do that same for when they give me a description of the account which would be a string. I used gets(name); /*name is my char array*/. But I don't know how to update because every time I did another account it printed out the new account name for the previous and new. Does anyone know how I can update this string array so I can print the old value and the new value?

    EX of output I want:
    Account #?
    1005(user input)
    Description:
    cash(user input)
    Amount?
    50
    prints: 1005 cash 50

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    For a job like this you'd be a lot further ahead to use an array of structs rather than multiple arrays. For one thing each struct can hold a complete account's information and for another, working with a single index there would be a lot less to go wrong...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Build an array of strings dynamically
    By Nazgulled in forum C Programming
    Replies: 29
    Last Post: 04-07-2007, 09:35 PM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. Array of strings in C
    By szill in forum C Programming
    Replies: 10
    Last Post: 02-22-2005, 05:03 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM