Question
I am trying to figure out why i am getting an array subscript error in dev c++. Here is my code, can I get help
I am trying to figure out why i am getting an array subscript error in dev c++. Here is my code, can I get help with this?
#include
using namespace std;
struct menuItemType { string menuItem; double menuPrice; };
//Function void getData(menuItemType[], int); void showMenu(menuItemType[], int); int makeOrder(int [], int); void printCheck(menuItemType[], int, int [], int);
int main() { menuItemType breakfastList[8]; int orderList[8]; int orderListSize = 0; getData(breakfastList, 8); showMenu(breakfastList, 8); orderListSize = makeOrder(orderList, 8); printCheck(breakfastList, 8, orderList, orderListSize); return 0; } void getData(menuItemType itemList[], int itemListLen) { ifstream inData; char ch; inData.open("ch9_Ex4Data.txt"); if(!inData){ cout << "Can not open int file (Error). Program terminates!"; return; } //inData >> itemList[0].menuItem; for (int i = 0; i < itemListLen; i++) { getline(inData, itemList[i].menuItem); inData >> itemList[i].menuPrice; inData.get(ch); } //close inData.close(); }
void showMenu(menuItemType menuItems[], int menuItemsSize){ cout <<"Welcome to Johnny's Restaurant"<
} return totalItemNumbers; } void printCheck(menuItemType[], int Size, int sArr[], int sArrSize){ double total = 0; for (int i = 0; i < sArrSize; i++){ cout << 1[sArr[i]].menuItems <<" "; cout << 1[sArr[i]].menuPrice << endl; total += 1[sArr[i]].menuPrice; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started