Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help finding out whats wrong with my code for case 3 i need to let the us

ID: 3659302 • Letter: I

Question

I need help finding out whats wrong with my code for case 3 i need to let the user create there order and then print it on the console thanks for the help! #include#include#define SIZE 25 typedef struct { char name[SIZE]; int id; int quan; float price; }BEER; BEER var[10]; int main () { FILE *f; f=fopen("beer.dat", "r"); int numBeer,tempQuan,tempId,searchId,choice; int i,j,n,p,q,h; int searchCount=0; float tempPrice; char tempName[SIZE]; //fscanf(f,"%d",&numBeer); BEER *beer; beer=(BEER*)calloc(numBeer,sizeof(BEER)); for(i=0;ibeer[p].price) { strcpy(tempName,beer[n].name); strcpy(beer[n].name,beer[p].name); strcpy(beer[p].name,tempName); tempId=beer[n].id; beer[n].id=beer[p].id; beer[p].id=tempId; tempQuan=beer[n].quan; beer[n].quan=beer[p].quan; beer[p].quan=tempQuan; tempPrice=beer[n].price; beer[n].price=beer[p].price; beer[p].price=tempPrice; } } } for(q=0;q<10;i++){ printf("Please enter a beer id # you wish to buy, if you are finished enter the # 1: "); scanf("%d",&searchId); if(searchId==1)break; for(j=0;j<10;h++){ printf(" %s Name: %d ID: $%d Quantity: %.2fPrice ",var[10].name,var[10].id,var[10].quan,var[10].price); } if(searchCount==0) { printf("Invalid Beer id "); } break; default: printf("Please Enter Valid Input (1,2,3) "); } fclose(f); return 0; }

Explanation / Answer

I think you lost some code during the copying. Please repost or pm me a copy of code. It would be better if you host it elsewhere and share a link. on another note, - you need to uncomment getting numBeer from file - you are missing your search fxn - I am not sure why you are using the keyword default with if-else statement

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote