struct array call by reference iteration problem

I wanted to pass the reference for every element of the book array instead of passing the whole book array to the inputbook function. The program would exit after the first iteration, but I know that data for the first iteration already got pass to the struct array. can anyone explain why?

The struct:

struct {
    char *title ;
    int number ;
    int quantity ;
} typedef book ;

main function:

int main (){
    int i, lim = 0; 
    book book[MAX] ;
    
    while (1){
        printf("%d\n", lim);
        inputbook(&book[lim]) ;
        lim ++ ;
    }
    return 0 ;
}

inputbook function:

void inputbook(book* temp){
    printf("Title: ");
    scanf ("%s", (*temp).title);
    printf("Quantity: ");
    scanf ("%d", &(*temp).quantity) ;   
}

1 answer