Here is a simple inventory program I made, please review it, and give me comments on how it could be fixed. Try not to add too much to it, just make it better.
Code:
//Keeps Track of a stores inventory
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char id[40];
char name[40];
char quanity[40];
const static char filename[]="inven.txt";
cout << "Product #:" << endl;
cin.getline(id,40);
cout << "Product Name:" << endl;
cin.getline(name,40);
cout << "Product Quanity:" << endl;
cin.getline(quanity,40);
ofstream inventory("inven.txt", ios::app);
if(inventory.bad())
{
cerr << "Error opening file" << filename << endl;
system("PAUSE");
}
else if(inventory.good())
{
cerr << "The data has been SUCESSFULLY added to" << " " << filename << endl << endl;
}
inventory << id << name << quanity;
ifstream a_file("inven.txt",ios::app);
a_file >> id >> name >> quanity;
cout << "Prouduct #:" << id << endl;
cout << "Product Name:" << name << endl;
cout << "Product Quanity:" << quanity << endl;
cin.get();
}