Program skips struct and goes straight to int main()

The program is functional, it's not complete though. I'm just trying to figure out how to put my input into the struct. When I run the program it takes me straight to int main(). But when I take the struct out and run it in a new window all alone it allows me to do the input. I'm trying to do input for 10 books. Thanks in advance to whatever help I might get!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string.h>

using namespace std;

// Function Prototypes
double CashierMod();
int InventoryMod();
double ReportMod();
char BookInfo();
char BookInput();
int menu();

const int SIZE=50;
const int PRECISION=2;
const int NUM_BOOKS=10;
const double Tax = 0.06;

double InvList, WholeSaleValue, RetailValue, QtyList, QtyCost, AgeList;
double Price, Sales_Tax, TotalSale, SubTotal;
char date;


struct Store
{
       char ISBN [SIZE];
       char title [SIZE];
       char author [SIZE];
       char publisher [SIZE];
       char dateAdded [SIZE];
       int onHand;
       double wholeCost;
       double retailCost;
};


char BookInput()
{
       int n;
       Store BookInput;
       
       for (n=0; n<NUM_BOOKS;n++)
       {
       cout<<"Enter the book's ISBN number: \n";
       cin.getline(BookInput.ISBN, SIZE);
       cout<<"Enter the title of the book: \n";
       cin.getline(BookInput.title, SIZE);
       cout<<"Enter the author of the book: \n";
       cin.getline(BookInput.author, SIZE);
       cout<<"Enter the publisher of the book: \n";
       cin.getline(BookInput.publisher,SIZE);
       cout<<"Enter the date the book was added: \n";
       cin.getline(BookInput.dateAdded, SIZE);
       cout<<"Enter the quantity of this book on hand: \n";
       cin>>BookInput.onHand;
       cout<<"Enter the wholesale cost of the book: \n";
       cin>>BookInput.wholeCost;
       cout<<"Enter the retail cost of the book: \n";
       cin>>BookInput.retailCost;
       }
       
       system ("pause");
       return 0;
       
};

// The Main Module.
int main ()
{
    struct Store;
    int selection;

    cout << fixed << showpoint << setprecision(2);
    do
    {
      selection = menu();
      switch(selection)
      {
         case 1 : CashierMod();
                  break;
         case 2 : InventoryMod();
                  break;
         case 3 : ReportMod();
                  break;
         case 4 : BookInfo();
                  break;
         case 5 : cout << "Exiting program.\n\n";
      }
    } while (selection != 5);
   return 0;

}

// The Main Menu Module.
int menu()
{
    int choice;
    cout << "S & E Book Store\n";
    cout << "\tMain Menu\n";
    cout << "----------------\n";
    cout << "1) Check Out\n";
    cout << "2) Inventory\n";
    cout << "3) Reports\n";
    cout << "4) Book Information\n";
    cout << "5) Exit Program\n";
    cout << "Enter 1, 2, 3, 4, or 5: \n";
    cin >> choice;
   while (choice < 1 || choice > 5) // Validate input
   {
      cout << "Invalid Selection. Enter 1, 2, 3, 4, or 5: ";
      cin >> choice;
   }
   return choice;
    
    
}

// The Cashier Module.
double CashierMod ()
{    
      
    int ISBN, Qty;  
    char date [SIZE];      
    cout << "S & E Book Store\n";
    cout << "\tCash Register Menu\n";
    cout << "----------------\n";
    cout << "Please enter today's date: \n";
    cout << "(Ex: 10-Nov-2008)"<<endl;
    cin >> date; // Example: 10-Nov-2008.
    
    cout << "Enter a valid ISBN: \n";
    cin >> ISBN;
    while (ISBN != 123)
    {
          cout << "Invalid selection. Enter a valid ISBN: \n";
          cin >> ISBN;
    }
          
    cout << "Enter quantity for purchase: \n";
    cin >> Qty;
    
    cout << fixed << showpoint << setprecision(2);
    
    // Calculate subtotal.
    
    SubTotal = ISBN * Qty;
    cout << "Subtotal: \n" << SubTotal;
    // Calculate tax.
    Sales_Tax = SubTotal * Tax;
    cout << "Sales Tax: \n" << Sales_Tax;
    // Calculate Total Sale.
    TotalSale = SubTotal + Sales_Tax;
    cout << "Total: \n" << TotalSale;
    

system ("Pause");
   return 0;
}


// The Inventory Database Module.
int InventoryMod()
{
    int choice;
    
    while (true)
        {
        //Display the menu and get a choice
                cout << endl;
        cout << "S & E Book Store\n";
        cout << "Inventory Database\n";
        cout << "------------------\n";
        cout << "1. Look-Up a Book\n";
        cout << "2. Add a Book\n";
        cout << "3. Edit a Books Record\n";
        cout << "4. Delete a Book\n";
        cout << "5. Return to the Main Menu\n";
        cout << endl;
        cout << "Enter your choice:" << endl;
        cin >> choice;
        switch (choice)
        {
                case 1: void lookUpbook();
                          break;
                case 2: void addBook();
                          break;
                case 3: void editBook();
                          break;
                case 4: void deleteBook();
                          break;
                case 5: cout << "Returning to main menu." << endl;
                          break;
        }

        //Validate and process the menu choice.
        while (choice < 1 || choice > 5)
        {
                cout << "Please enter a number between one and five." << endl;
                cin >> choice;
        }
        } while (choice != 5);
        return 0;
}

//Add stub functions for inventory database

char lookUpBook()
{
	//Get the title of the book to search for
        cout << "Enter the title of the book you wish to search for. " << endl;
        
}


// The Report Module.
double ReportMod ()
{
       int choice;
       
       cout << "S & E Book Store\n";
       cout << "\t Reports\n";
       cout << "----------------\n";
       cout << "1) Inventory Listing\n";
       cout << "2) Inventory Wholesale Value\n";
       cout << "3) Inventory Retail Value\n";
       cout << "4) Listing by Quantity\n";
       cout << "5) Listing by Cost\n";
       cout << "6) Listing by Age\n";
       cout << "7) Return to the Main Menu\n";
       cin >> choice;
       while (choice < 1 || choice > 7) // Validate input
   {
      cout << "Invalid Selection. Enter 1, 2, 3, 4, 5, 6, or 7: ";
      cin >> choice;
   }
   return choice;
       
}

// The Book Info Module.
char BookInfo()
{
     cout << "S & E Book Store\n";
     cout << "Book Information\n";
     cout << "----------------\n";
     cout << "ISBN: \n";
     cout << "Title: \n";
     cout << "Author: \n";
     cout << "Publisher: \n";
     cout << "Date Added: \n";
     cout << "Quantity on Hand: \n";
     cout << "Wholesale Cost: \n";
     cout << "Retail Price: \n";
     
     system ("Pause");
     return 0;

}
Execution begins at the first line of main() regardless of what appears before it. How are you expecting BookInput() to be called?
Topic archived. No new replies allowed.