B
Brian
I am trying to open a file in the classes contructor. The file is
created and the program even thinks it is open and tries to write to
it with no errors, but when I look at the file it is zero
bytes..nothing was written to it. Here is part of my code if anyone
can help me. I do appreciate it.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include "stdio.h"
using namespace std;
class file_handler
{
private:
ofstream outfile;
public:
char InventoryNumber[16];
char ProductName[21];
char ProductCode[4];
int OnHandQuantity;
int BackOrderQuantity;
int OnOrderQuantity;
float InventoryEvaluation;
float AverageCost;
float SellingPrice;
file_handler();
file_handler(string file);
~file_handler();
int write_file();
file_handler::~file_handler()
{
outfile.close();
}
file_handler::file_handler(string file)
{
outfile.open(file.c_str(),ios:
ut|ios::app|ios::binary);
}
file_handler::write_file()
{
//writing file stuff
}
int main()
{
file_handler newfile("inventory.dat")
}
created and the program even thinks it is open and tries to write to
it with no errors, but when I look at the file it is zero
bytes..nothing was written to it. Here is part of my code if anyone
can help me. I do appreciate it.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include "stdio.h"
using namespace std;
class file_handler
{
private:
ofstream outfile;
public:
char InventoryNumber[16];
char ProductName[21];
char ProductCode[4];
int OnHandQuantity;
int BackOrderQuantity;
int OnOrderQuantity;
float InventoryEvaluation;
float AverageCost;
float SellingPrice;
file_handler();
file_handler(string file);
~file_handler();
int write_file();
file_handler::~file_handler()
{
outfile.close();
}
file_handler::file_handler(string file)
{
outfile.open(file.c_str(),ios:
}
file_handler::write_file()
{
//writing file stuff
}
int main()
{
file_handler newfile("inventory.dat")
}