Hi, having a problem with something I am trying to do in C. This is the code I have:
#include <stdio.h>
int main()
{
#define MAX 10
int i;
struct list_details
{
char make[45];
char model[45];
} carList[10];
for(i=0; i < MAX;i++)
{
printf("Enter the make : \n");
scanf("%s", &List[i].make);
printf("Enter the model : \n");
scanf(%s", &List[i].model);
}
return 0;
}
This keeps asking for a make and model for up to 10 times, however I want it so that you can input up to 10 times but can also quit before if needed. E.g. if you only want to put 3 records in then you can quit after entering the third record. I have been trying this using getchar() but just can't seem to get it to work.
Please help.