#include #include #include #include // !! You had no use for iomanip using namespace std; struct ITM_TYPE { std::vector< std::pair< std::string, float > > items; int seatN; }; // !! You had an unused function here int main() { // !! These had no business being global variables int N_ITEMS; int N_SEATS; int seat; int tItems = 0; cout << "Enter the number of seats: "; cin >> N_SEATS; //retrive number of seats // !! This is not needed if you iterate starting at 0 N_SEATS += 1; // !! You can not dynamically create arrays like you did. Do it like below // !! Also you used N_ITEMS incorrectly as opposed to N_SEATS // !! This was also out of scope inside the for (the second for did not know it existed) // !! Plus it was being re-created on every iteration std::vector< ITM_TYPE > items; for( seat = 1; seat < N_SEATS; seat++ ) // loop for each seat { cout << "Enter number of items for seat" << seat <<": "; cin >> N_ITEMS; //get number of items for seat tItems += N_ITEMS; string name; float price; ITM_TYPE nItem; nItem.seatN = seat; // !! If you are initializing an iterator variable, then incrementing on each // !! loop, then just use a for instead of a while. Thats why it exists for( int i = 0; i < N_ITEMS; i++ ) { cout << "Input item name: "; cin >> name; cout << "item[" << i << "].name SET" << endl; cout << "Input item price: "; cin >> price; cout << "item[" << i << "].price SET" << endl; nItem.items.push_back( std::pair< std::string, float >( name, price ) ); } items.push_back( nItem ); } for( int i = 0; i < items.size( ); i++ ) { std::cout << "Seat #" << i + 1 << std::endl; for( int j = 0; j < items[ i ].items.size( ); j++ ) std::cout << "Name: " << items[ i ].items[ j ].first << "\nPrice: " << items[ i ].items[ j ].second << std::endl; } system( "pause" ); // !! You did not indicate a successful end of program return 0; }