I'm writing a program that reads in data from an input file and then in the report module it is supposed to ask the user to type in the item it wants to look up and display all of the information stored for that item on the screen. I am receiving the following error messages:
c:\my documents\c++\project_2.cpp(120) : error C2143: syntax error : missing ')' before ';'
c:\my documents\c++\project_2.cpp(120) : warning C4552: '<' : operator has no effect; expected operator with side-effect
c:\my documents\c++\project_2.cpp(120) : error C2059: syntax error : ')'
c:\my documents\c++\project_2.cpp(121) : error C2143: syntax error : missing ';' before '{'
All of the errors are in the report module in the section that is blue.
Code:
#include<iostream>
#include<String>
#include <ios>
#include <fstream>
using namespace std;
void printMenu(int &selection);
void startSystem();
void login();
void modify();
void report();
void exitSystem();
int count=0;
string inventory[50];
string item[50];
string vendor_name[50];
double vendor_price[50];
double retail_price[50];
int number[50];
int main()
{
int selection;
startSystem();
//menu
printMenu(selection);
while(selection !=4)
{
if (selection==1)
login();
else if (selection==2)
modify();
else if (selection==3)
report();
else if (selection==4)
exitSystem();
else
cout<<"You entered and invalid number.";
printMenu(selection);
}
return 0;
}
void printMenu(int &selection)
{
system("cls");
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<" Acme Department Store Inventory System"<<endl<<endl;
cout<<" 1. Log into System"<<endl;
cout<<" 2. Modify Inventory"<<endl;
cout<<" 3. Report Section"<<endl;
cout<<" 4. Exit the system"<<endl;
cout<<endl;
cout<<" What would you like to do? ";
cin>>selection;
}
void startSystem()
{
ifstream input;
input.open("invent.dat");
while (!input.eof())
{
input>>inventory[count]>>item[count]>>vendor_name[count]>>vendor_price[count]>>retail_price[count]>>number[count];
cout<<"The inventory number is "<<inventory<<endl;
cout<<"The item name is "<<item<<endl;
cout<<"The vendor name is "<<vendor_name<<endl;
cout<<"The vendor price is "<<vendor_price<<endl;
cout<<"The retail price is "<<retail_price<<endl;
cout<<"The number in stock is "<<number<<endl;
count=count+1;
}
input.close();
}
void login()
{
cout<<"In login"<<endl;
system ("pause");
}
void modify()
{
cout<<"In modify"<<endl;
system ("pause");
}
void report()
{
int choice, i;
string num, department;
ifstream input;
//report menu
system("cls");
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<<" Report Menu"<<endl;
cout<<" ==========="<<endl;
cout<<" 1. Report by inventory item"<<endl;
cout<<" 2. Report by Department"<<endl;
cout<<" 3. Report by Vendor"<<endl;
cout<<" 4. All items in stock"<<endl;
cout<<" 5. Exit Report Menu"<<endl;
cout<<endl;
cout<<" What would you like to do?";
cin>>choice;
if (choice==1)
{
cout<<"Enter the inventory number ";
cin>>num;
while(i = 0; i < count; i++)
{
if(num==inventory[i])
{
cout<<inventory[i]<<" "<<item[i]<<" "<<vendor_name[i]<<" "<<vendor_price[i]<<" "<<retail_price[i]<<" "<<number[i]<<endl;
system("pause");
}
else
{
cout<<"There is no such item in inventory"<<endl;
system("pause");
}
}
}
}
void exitSystem()
{
ofstream output;
output.open("invent.dat");
output<<inventory<<" "<<item<<" "<<vendor_name<<" "<<vendor_price<<" "<<retail_price<<" "<<number<<endl;
output.close();
}
[code][/code]tagged by Salem
You made it all so pretty, yet forgot the most important ones to make the code readable...