My code isn't working after the second scanf statement. I'm still new to C++ so im not sure what I am doing wrong. I've looked on this website as well as others and so far havent found anything. I've also tried the fflush statement but that didnt fix it either, any other suggestions would be great thanks.
include <stdio.h>
int main(void)
{
//Intro message
printf("This program will take the order of a customer and then subtract their order from the inventory list. After calculations a new inventory list will appear\n");
// declare variables
int dough, sauce, cheese, pepperoni, sausage, greenPeppers, blackOlives, mushrooms;
int num1;
char pizza;
// create inventory
dough = 50;
sauce = 50;
cheese = 50;
pepperoni = 50;
sausage = 50;
greenPeppers = 50;
blackOlives = 50;
mushrooms = 50;
//display the inventory
printf("\n The currrent inventory is: \n Dough:%d", dough);
printf("\n Sause:%d", sauce);
printf("\n Cheese:%d", cheese);
printf("\n Pepperoni:%d", pepperoni);
printf("\n Sausage:%d", sausage);
printf("\n Green Peppers:%d", greenPeppers);
printf("\n Black Olives%d", blackOlives);
printf("\n Mushrooms:%d", mushrooms);
//get customer input
printf("\nWhat type of pizza would you like? Please type a lowercase letter and only chose one. Type C for Cheese, P for Pepperoni, S for Sausage, and V for Veggie.\n");
scanf_s(" %c", &pizza);
printf("\nHow many pizzas would you like to order? Maximum of 10.\n");
scanf_s(" %d", &num1);
//This is where it stops
printf("It cuts out here, why can I not see anything after this line?");
// calculate what inventory will be taken out
cheese = cheese - num1;
dough = dough - num1;
sauce = sauce - num1;
switch (pizza)
{
case 'c':
cheese = 50 - num1;
break;
case 'p':
pepperoni = pepperoni - num1;
break;
case 's':
sausage = sausage - num1;
break;
case 'v':
blackOlives = blackOlives - num1;
greenPeppers = greenPeppers - num1;
mushrooms = mushrooms - num1;
break;
}
// display final inventory
printf("The new inventory is: \n Dough:%d", dough);
printf("\n Sause:%d", sauce);
printf("\n Cheese:%d", cheese);
printf("\n Pepperoni:%d", pepperoni);
printf("\n Sausage:%d", sausage);
printf("\n Green Peppers:%d", greenPeppers);
printf("\n Black Olives%d", blackOlives);
printf("\n Mushrooms:%d", mushrooms);
return 0;
}