Hi again.
Since i've bypassed the login system, i've not tried to create a simple reading and writing to a file system to keep track of business records.
Here are the code snippets:
..that is the record data function, and here is the read data funcion:Code:std::string DatabaseMgr::sRecordData() { std::system("cls"); std::ofstream File_Input("Record.txt", std::ios::app); std::cout << "Welcome, please record the data as follows:" << std::endl; std::cout << "\nNote! Do not place spaces inbetween words when recording\nnew products, this will crash the application!" << std::endl; std::cout << "\nProduct Purchased:"; std::cin >> m_cProduct; /* std::cout << "\nDate the Transaction was made: "; std::cin >> m_sDatePurchased; std::cout << "\nQuantity of the Purchased Item: "; std::cin >> m_iQuantity;*/ std::cin.getline(m_cProduct, 50); File_Input << m_cProduct << "\n"; File_Input.close(); std::cout << "Thank you for recording!" << std::endl; vReturnToStart(); }
I C&R'd the whole program with no errors, untill i get a run-time error!Code:void DatabaseMgr::vReadData() { std::system("cls"); std::cout << "Here are the records you requested: " << std::endl; std::ifstream File_Output("Record.txt"); while(File_Output.get(m_cBuffer)) { std::cout << m_cBuffer; } std::cout << "\n\nThank you for reading our records!" << std::endl; File_Output.close(); std::cin.ignore(); vReturnToStart(); }
I can write to the file just fine, but my program will not let me read the text! I will post a screenie to elaborate.
Can anybody tell me what i've done wrong?



LinkBack URL
About LinkBacks




fstream File_Input("Record.txt", std::ios::app);
