So I'm going to post a big section of code just so you can see what I'm working with.
char isbnHold[13]; /* holds isbn to do calculations */
strncpy(isbnHold,structBuffer.isbn,13); /* copies isbn into hold */
if((checkISBN(isbnHold))==0){
printf("made it in");
int k;
int checkInt;
for(k=0;k<4;k++){
if(strcmp(structBuffer.isbn,structArray[k].isbn)!=0){
checkInt=1;
printf("Or did something go wrong here?");
}
else if(strcmp(structBuffer.isbn,structArray[k].isbn)==0){
checkInt=0;
printf("Did we get to here?");
k=5;
}
}
if(checkInt==0){
if(structBuffer.requestType == Query){
printf("is it getting here?\n");
int i;
for(i=0;i<4;i++){
if(strcmp(structBuffer.isbn,structArray[i].isbn)==0){
returnStruct.respType = Okay;
returnStruct.requestID = structBuffer.requestID;
strncpy(returnStruct.isbn,structArray[i].isbn,13);
strncpy(returnStruct.authors,structArray[i].authors,100);
strncpy(returnStruct.title,structArray[i].title,100);
returnStruct.edition = structArray[i].edition;
returnStruct.year = structArray[i].year;
strncpy(returnStruct.publisher,structArray[i].publisher,100);
returnStruct.inventory = structArray[i].inventory;
returnStruct.available = structArray[i].available;
}
}
}
else if(structBuffer.requestType == Borrow){
int j;
for(j=0;j<4;j++){
if(strcmp(structBuffer.isbn,structArray[j].isbn)==0){
if(structArray[j].available > 0){
returnStruct.respType = Okay;
returnStruct.requestID = structBuffer.requestID;
strncpy(returnStruct.isbn,structArray[j].isbn,13);
strncpy(returnStruct.authors,structArray[j].authors,100);
strncpy(returnStruct.title,structArray[j].title,100);
returnStruct.edition = structArray[j].edition;
returnStruct.year = structArray[j].year;
strncpy(returnStruct.publisher,structArray[j].publisher,100);
returnStruct.inventory = structArray[j].inventory;
returnStruct.available = structArray[j].available;
structArray[j].available = (structArray[j].available-1);
}
}
else{
returnStruct.respType = AllGone;
}
}
}
else if(structBuffer.requestType == Return){
int x;
for(x=0;x<4;x++){
if(strcmp(structBuffer.isbn,structArray[x].isbn)==0){
returnStruct.respType = Okay;
returnStruct.requestID = structBuffer.requestID;
strncpy(returnStruct.isbn,structArray[x].isbn,13);
strncpy(returnStruct.authors,structArray[x].authors,100);
strncpy(returnStruct.title,structArray[x].title,100);
returnStruct.edition = structArray[x].edition;
returnStruct.year = structArray[x].year;
strncpy(returnStruct.publisher,structArray[x].publisher,100);
returnStruct.inventory = structArray[x].inventory;
returnStruct.available = structArray[x].available;
structArray[x].available = (structArray[x].available+1);
}
}
}
}
else if(checkInt==1){
returnStruct.respType = NoInventory;
}
}
I realize this is a lot to look at but if it is a syntax error I it is probably necessary to have it all. As you can see I'm checking the value of a function. I know that this value is 0 because at one point I had a printf statment to tell me what the value of it was. However you can see the other printf statements I am using to debug and none of those are being printed. I don't know why it is skipping this block but any help would be appreciated. It enters the else if block of the return value being 1 if an invalid ISBN entered.
Aucun commentaire:
Enregistrer un commentaire