Thread: Need advice to solve a problem

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    92

    Need advice to solve a problem

    Hello
    I need some help. In my program the user must enter the number of customers then they must enter a customer number for each customer and how current the customer is using.

    Something like this

    Customer 1
    Customer Number: 100
    Current Usage: 153A

    The user must enter the number of customers first then later in the program he/she will fill in all the details like customer number and current usage. A friend of mine told me that linked lists would be the best way to do this; can someone please tell me where I can find an example of a linked list that does something similar to this. If linked list is not the right way to about it feel free to make any suggestions that you think will help

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I wouldn't trust a user to enter a customer number if you want it done correctly. I would change your program so it would take on this task, reading the proper info, from a file.

    A linked list is great, but your data in the list will disappear when the program closes. Is that OK? A file with the data may be what you want, which would get updates when new customers are added.

    For linked list info, check our forum FAQ's, and of course, the forum search function as well. There are many threads having to do with linked lists. Google has a ton of stuff on it, as well.

    When you need some specific help and have some background on it, post up your code and we'll help out.

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    9
    Quote Originally Posted by HAssan View Post
    Hello
    I need some help. In my program the user must enter the number of customers then they must enter a customer number for each customer and how current the customer is using.

    Something like this

    Customer 1
    Customer Number: 100
    Current Usage: 153A

    The user must enter the number of customers first then later in the program he/she will fill in all the details like customer number and current usage. A friend of mine told me that linked lists would be the best way to do this; can someone please tell me where I can find an example of a linked list that does something similar to this. If linked list is not the right way to about it feel free to make any suggestions that you think will help
    How comfortable are you with data structures? If you are just starting out with programming, I'd suggest you go the easy (and limited) way of using an array of structures. I know, this will impose a constraint on the maximum number of entries that can be read in one execution of the program and also lead to waste of space, but it will be easier to implement. Are you comfortable with dynamic memory allocation? If you are, only then go for linked lists.

    And yes, like Adak said, if you want to entries entered to persist after the program terminates, write them out to a file (if you have done file handling in C).

  4. #4
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    soif i understand you correctly you just have a menu
    and you enter customers data
    and you want to keep the data after you end the function.

    if its true

    then i would used linked list
    do a while loop
    which breaks of some condition and create a new next node for each new customer.

    and then return the head of the list.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Solve This Problem Within 3 Hr Urgent Need
    By annum in forum C Programming
    Replies: 12
    Last Post: 10-04-2009, 09:56 AM
  2. Problem I can't seem to solve
    By psykik in forum C Programming
    Replies: 15
    Last Post: 05-19-2005, 12:18 PM
  3. problem solve
    By coolnarugodas in forum C Programming
    Replies: 7
    Last Post: 04-26-2005, 12:31 PM
  4. Replies: 2
    Last Post: 04-25-2005, 11:59 AM
  5. problem cant solve please help.
    By sarah in forum C Programming
    Replies: 6
    Last Post: 09-03-2001, 01:32 PM