Simple Concept Progaram Problem; Ends After Input

Here is my header file:

//Ian Forsyth
#include<fstream.h>
#include<iostream.h>
#include<iomanip.h>
#include<stdlib.h>

struct inventory
{
char title[80];
char author[80];
double whole;
double retail ;
double tax;
double cost;
};

const int Index=100;

int menu();
int doInput();
double doOutput(int checker, inventory thisOne[]);


Here is my implementation:\
#include "filesTry2.h"

int main()
{
cout<<"This is a Book program.\n";
menu();
return;
}


And here is the application file:
//Ian Forsyth
#include "filesTry.h"

int menu()
{
int choice=0;
cout<<"What would you like to do?\n";
cout<<"\t1. Run\n";
cout<<"\t2. End\n";

cin>>choice;
if(choice==2)
{
return(0);
}
doInput();
return(0);
}
int doInput()
{
int counter;
int checker;
char junk;

struct inventory thisOne[Index];

cout<<"How many books are you stocking?\n";
cin>>checker;

cin.get(junk);
for(counter=0; counter<checker; counter++)
{
checker+
cout<<("Enter the book's title:\n");
cin.getline(thisOne[counter].title, 79);
cout<<("Enter the book's author:\n");
cin.getline(thisOne[counter].author, 79);
cout<<("Enter the item's whole sale cost:\n");
doOutput(checker, thisOne);
cin>>thisOne[counter].whole;

cout<<"Checker: "<<checker<<"\n";
cout<<"Counter: "<<counter<<"\n";
}
doOutput(checker, thisOne);
return(0);
}
double doOutput(int checker, inventory thisOne[])
{
int counter;
double allTax, allCost;

for(counter=0; counter<checker; counter++)
{
thisOne[counter].retail=(thisOne[counter].whole*.65)+thisOne[counter].whole;
thisOne[counter].tax=(thisOne[counter].retail*.65);
thisOne[counter].cost=thisOne[counter].tax+thisOne[counter].retail;
}

for(counter=0; counter<checker; counter++)
{
cout.flags(ios::fixed);
cout<<setprecision(2)<<"TITLE: "<<thisOne[counter].title<<"\n";
cout<<setprecision(2)<<"AUTHOR: "<<thisOne[counter].author<<"\n";
cout<<setprecision(2)<<"WHOLE: "<<thisOne[counter].whole<<"\n";
cout<<setprecision(2)<<"RETAIL: "<<thisOne[counter].retail<<"\n";
cout<<setprecision(2)<<"COST: "<<thisOne[counter].cost<<"\n";
}

for(counter=0; counter<checker; counter++)
{
allCost+=thisOne[counter].cost;
allTax+=thisOne[counter].tax;
}
cout<<setprecision(2)<<"\n\n\nTOTAL TAX: "<<allTax<<"\n";
cout<<setprecision(2)<<"TOTAL COST: "<<allCost<<"\n";
return(0);
}


My probelm is with the for loop inputing data into the structure. It runs in the console and I can input the title, author, and wholesale cost. However, after inputing the wholsale cost the program ends (ending meaning "Press any key to continue and then terminating). The same thing happens if it's not a loop. The same things happens if I try to terminate the loop. The same thing happens if I input title or author last. It dies if I try to input 2 or 3 books. Basically it dies after the last input, period. Any help would be amazing...I, my whole class, and teacher are stumped. Thanks a lot.
In main you should return 0
In doInput you have the first line in the loop which is checker+ and it's wrong
In doOutput you are not initializing allTax nor allCost but you are incrementing them (+=)
Okay I fixed those minor problems (the checker+ is accidentally left over from my last attempt at fixing the problem...sorry) but they did not have any effect on the serious issue of terminating after input. Any more help?
Topic archived. No new replies allowed.