int regMedicine(Medicine lakemedel[], int antalMedicine)
{
char namnMed[WORDLENGTH], tmp[WORDLENGTH], test[WORDLENGTH] = "ja";
int storlek, saldo;
while(strcmp(test, "ja") == 0)
{
printf("Ange namn: ");
gets(namnMed);
printf("Ange storlek: ");
while(tmp!=0){ ///////////////////////
gets(tmp); //////////////////////////////////////////
} ///////////////////////////////////
storlek = atoi(tmp); //atoi - converts string to int
printf("Ange saldo: ");
gets(tmp);
saldo = atoi(tmp); //atoi - converts string to int
lakemedel[antalMedicine] = createMedicine(namnMed, storlek, saldo);
antalMedicine++;
printf("Vill du fortsatta registrera (ja) eller (nej): ");
gets(test);
}
return antalMedicine;
}
I am writing a program where I use a FILE to register the medicine, size of the medicine and balance. I wrote a function where I can take the name of medicine, size and balance. But the problem I got stuck is how to add few sizes of medicine and quit by entering "0". Any Ideas? Should I use an extra loop?