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
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.
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.
first define your structure.
now you need to declare an array of the above type
This gives you an array of MAX number of your structure
struct car car_array[MAX];
now you can get input from user
now you can sort the array, what are you sorting by, make, model etc
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 */
as for sorting algorithms... look out for quick / merge / shell [my personal favorite] / bubble... etc...
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.