Hello people, I'm trying to make a program that will simulate a software to control an library, look at my code:
Code:
struct book *findbook (struct book books[], int pcode) {
struct book *b;
for (b = books; b->code; b++)
if(b->code == pcode)
return b;
return NULL;
}
This function is supposed to find a book (the structure) by his ID, in the case I don't find it, it returns NULL. Ok, it works perfectly when you send existents products, but when I send an inexistent product, it freezes my program. I'm calling this function from the other function:
Code:
void supply(void) {
int code, qnt;
struct book *bk;
system("cls");
printf("Enter the code of the product: ");
scanf("%d",&code);
printf("Enter number of units to supply: ");
scanf("%d",&qnt);
bk = findbook(books,code);
if(bk)
updtqnt(bk,qnt);
}
This always fail, someone can please help me?