Note that there are some explanatory texts on larger screens.

plurals
  1. POMenu not working properly
    text
    copied!<pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; //for the clear screen function #include &lt;string.h&gt; struct customer { int custID; char custName[50]; char custAddress[100]; }; typedef struct customer c; void load_menu(void); void customers_menu(void); void createNew(void); //initialize your file void add_Customer(c c1[30]); //add a new record to the file FILE *fp; int main(void) { load_menu(); return 0; } void load_menu(void) { int choice; do { printf("Customer Orders Main Menu. \n\n"); printf("Please enter your choice: \n"); printf("1. Customer's Menu \n"); printf("2. Orders Menu\n"); printf("3. Product Stock Menu\n"); printf("4. Exit\n"); printf("\n"); if (scanf("%d",&amp;choice)==1) { switch(choice) { case 1: system ("cls"); customers_menu(); printf("\n"); break; case 2: system ("cls"); orders_menu(); printf("\n"); break; case 3: system ("cls"); stock_menu(); printf("\n"); break; case 4: printf("Quitting program!\n"); break; default: printf("Invalid choice! Please try again\n"); printf("\n"); break; } } else { fflush(stdin); printf("Characters are invalid, please enter a number: \n "); choice=0; } }while((choice !=4)); } void createNew(void) { FILE *fp; fp=fopen("Customer.dat", "w"); if (fp==NULL) printf("File creation failed! \n"); else { printf("File created! \n"); fclose(fp); } } void add_Customer (c c1[30]) { int i, n , cc=0; FILE *fp; fp=fopen("Customer.dat", "a"); system("cls"); if(fp==NULL) { printf("File Creation Failed!"); } system("cls"); printf("Enter the number of Customers: "); scanf("%d", &amp;n); for(i=0;i&lt;n;i++) { printf("Customer's ID (numbers only) : "); scanf("%d", &amp;c1[i].custID); printf("Customer's Name : "); gets(c1[i].custName); printf("Customer's Address : "); gets(c1[i].custAddress); fwrite(&amp;c1[i], sizeof(c), 1, fp); }cc++; fclose(fp); } void recordCount(c c1[30], int *count) { add_Customer(c1); count=0; count++; } void customers_menu(void) { int choice; c c1[30]; int i; do { printf("\n"); printf("Customers Menu \n\n"); printf("Please enter your choice: \n"); printf("1. Add Customer \n"); printf("2.\n"); printf("3.\n"); printf("4. Go back to Main Menu \n"); recordCount (c1, &amp;i); if (scanf("%d",&amp;choice)==1) { switch(choice) { case 1: add_Customer(c1); createNew(); printf("\n"); break; case 2: printf("\n"); break; case 3: printf("\n"); break; case 4: printf("Going back to Main Menu\n"); system ("cls"); break; default: printf("Invalid choice! Please try again\n"); printf("\n"); break; } } else { fflush(stdin); printf("Characters are invalid, please enter a number: \n "); choice=0; } }while((choice !=4)); </code></pre> <p>I have a problem since when I enter the Customers Menu it is staring to execute case 1 immediately (which still doesn't work properly). Can someone help me fix this error please because I tried everything I know and it is still in vain</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload