inventory program

This is a discussion on inventory program within the C Programming forums, part of the General Programming Boards category; ok here's the deal i have to make a prog that ask the user how many cars that they want ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    9

    inventory program

    ok here's the deal i have to make a prog that ask the user how many cars that they want to enter, then prompt them for the make, model, year, color, price. Then sorts the info anyway the user wants it. So here's the problem, what do i have to do to make the program get the information and then store it so that i can sort it. I have to do this using structures, but i can't figure it out. i just need someone to point me in the right direction.

    any help would be great
    thanks

    --ManicC--

  2. #2
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    Have you got some code you can post? you really should have a go yourself first as people here will be reluctant to help otherwise.
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    9
    well see that's the problem is i have a lot of code that wasn't even close to right. I'm not asking for anyone to give me code i just needed any ideas as to how i should go about doing this.

    this was my idea, but it's doesn't seem very efficient.

    do all i need is one stucture then, just ask for input, then assign the input to a struture variable. but then do assign that input to an array so that i can sort it. i don't know i'm lost on this one.

  4. #4
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    Posts
    523
    first define your structure.
    Code:
    struct car{
         char make[12];
         char model[12];
         int  year;
         char color[12];
         float price;
    };
    now you need to declare an array of the above type
    Code:
    struct car car_array[MAX];
    This gives you an array of MAX number of your structure
    now you can get input from user
    Code:
    for(int i=0; i<MAX; i++)
    {
         printf("\nEnter car make: ");
         fgets(car_array[i].make, sizeof(make)-1, stdin);
         /* code for rest of input */
    }
    now you can sort the array, what are you sorting by, make, model etc
    All spelling mistakes, syntatical errors and stupid comments are intentional.

  5. #5
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    as for sorting algorithms... look out for quick / merge / shell [my personal favorite] / bubble... etc...
    hasafraggin shizigishin oppashigger...

  6. #6
    Registered User
    Join Date
    Nov 2001
    Posts
    9
    Hey thanks a lot C_Coder, i really wasn't expecting that much of a detailed reply. By the way yes, i'm sorting according to make, model, etc. using a bubble sort.
    again thanks

    --ManicC--

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 11:58 PM
  2. Can someone look over the program I wrote?
    By brooklyn in forum C++ Programming
    Replies: 10
    Last Post: 04-16-2006, 08:23 AM
  3. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  4. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 08:51 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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