This thing will not write to the file, please help!
Thanks!Code:/* Use data from keyboard to create a binary file of fixed length records */ #include <iostream> #include <fstream> #include <string> using namespace std; struct info { char inv_num [16]; char prod_name [21]; char prod_code [4]; int oh_qty; int bo_qty; int oo_qty; float inv_eval; float avg_cost; float sell_price; }; class inventory { protected: public: ofstream file; inventory() { ofstream file("inventory.dat", ios::out | ios::app | ios::binary); } ~inventory() { file.close(); } void write_data(info &i) { file.write((char*) &i,sizeof(i)); } }; int main () { inventory go; info x; cout << endl << "Inventory Number: "; cin.getline (x.inv_num, 16); go.write_data(x); return 0; }



LinkBack URL
About LinkBacks


