i have written a code it is my college assignment for tomorrow, the program runs ok but it just wont work
the code is a long one 400... lines ill just take the neccessary parts if needed i can upload the full code
my struct :
Code:
// the struct which defines each cars properties.
struct car{
char *plate;
char *brand;
char *model;
char *color;
char *status;
int productionyear;
int price;
};// Struct ends
the part where i call the mistaken function
Code:
Car gallery[20];
// we initialize the cars before everything else
initialize(gallery);
// the main loop
while(selection2 == 1)
{
system("CLS");// clears the screen incase of previous restarts
// Welcome Prints/Main Loop
printf("Welcome to my gallery please make your selection : \n\n");
printf("\n1 - Add a new car\n2 - Update an information of a selected car\n3 - Rent a Car\n4 - Taking back a car\n5 - Searching an available car\n\nEnter your selection : ");
//Selection of main loop
scanf("%d",&selection);
if(selection == 1){
carcounter++;// when we add a new car we make sure the size of the loop there (check addcar())
addcar(gallery,carcounter)
and the whole function that causes my error
Code:
void addcar(Car *aCar,int i){
// the string variables in order for scanf to read the string properly with also a size of 20
char *plateA[20];
char brandA[20];
char modelA[20];
char colorA[20];
char statusA[20];
// end of variables
// read plateA and assign to struct
printf("Enter plate of the car : ");
scanf("%s",&plateA);
aCar[i].plate = plateA;
// end plate sscan
// read brandA and assign to struct
printf("Enter the brand of the car : ");
scanf("%s",&brandA);
aCar[i].brand = brandA;
// end brand scan
// read modelA and assign to struct
printf("Enter the model of the car : ");
scanf("%s",modelA);
aCar[i].model = modelA;
// end model scan
// read colorA and assign to struct
printf("Enter the color of the car : ");
scanf("%s",colorA);
aCar[i].color = colorA;
// end color scan
// read statusA and assign to struct
printf("Enter the status of the car : ");
scanf("%s",statusA);
aCar[i].status = statusA;
// end status scan
// start production year scan not neccesarily need a local variable as it wont have any
// difference from the variable in our struct
printf("Enter the production year of the car : ");
scanf("%d",&aCar[i].productionyear);
// end production year scan
// start price scan
printf("Enter the price of the car : ");
scanf("%d",&aCar[i].price);
// nice success message
printf("Car has been added : \n");
// briefing of the car added
printf("%s , %s , %s , %s , %s , %d , %d",aCar[i].plate,aCar[i].brand,aCar[i].model,aCar[i].color,aCar[i].status,aCar[i].productionyear,aCar[i].price);
}
i can even attach the zip of the whole project if anyone is willing to help
thanks in advance