Hello all,
I am new to C programming.
Need to create a sparse matrix of cars and dealers.
I created a struct of a car, and an array of cars that holds these cars (say, after production).
Also I created a dealer struct and array of dealers to hold the dealers.
Problem #1
My issue is that although cars exist on their own (in the array of cars), I need to add these cars to dealers within the dealer array.
I should then be able to run a report on all cars that a dealer has by stepping through the dealer array and looking at each dealer's cars.
Problem #2
I need to run a report each car manufactured to see what dealer they are at. This will require stepping through cars in the car array and finding out what dealer they are at. SO there needs to be some type of "active" link between the car and dealer, and I need to be able to trace "backwards" to find out where the car ended up.
Note for above, per my project specs: I am not allowed to duplicate records, that is, I cannot maintain BOTH a list of dealer records for each car, and a list of car records for each dealer (which is why I chose to create only a list of cars for each dealer)...
Problem #4
Obviously this is not a sparse matrix yet.. But am I on the correct path storage-wise? Any hints?
Code:
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include <stdio.h>
struct car{
char * make[39]; //
int id;
};
struct car cars[] = {};
struct dealer{
char * name[];
int id;
// struct car cars[] = {}; ???????????
};
struct dealer dealers[] = {};
int main (int argc, char *argv[])
{
car myCar;
*myCar.make = "GMC";
myCar.id = 1;
cars[0] = myCar;
dealer aDealer;
*aDealer.name = "Smith's GMC";
aDealer.id = 201;
// add cars to the dealer
system("PAUSE");
return EXIT_SUCCESS;
}