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

#include<stdio.h> #include <string.h> #include <math.h> #define MAXIMUM_LENGTH30

ID: 3612928 • Letter: #

Question

#include<stdio.h>
#include <string.h>
#include <math.h>

#define MAXIMUM_LENGTH30

struct inventory_node{
int data;
struct inventory_node *left;
struct inventory_node *right;
};


int main()
{
    int num_of_commands;
    FILE * store;
    store = fopen("inventory.txt","r");
    fscanf(store, "%d", &num_of_commands);
    printf("%d", num_of_commands);
    int i;
    for(i = 1; i < num_of_commands; i++){
         
         printf(" ");

    intchoices;
    char itemname[MAXIMUM_LENGTH];
    int price;
    int j;
    for(j=1; j <=choices; j++){
    fscanf(store, "%d", &choices);
    fscanf(store, "%s", itemname);
    printf("%d " "%s ", choices, itemname);
}
}

   
fclose(store);
system("Pause");
return 0;
}

Explanation / Answer

The choices variable iscurrently not initialized so you get no prints. It should be read before the second loop: fscanf(store, "%d", &choices); for(j=1; j