I made a small text file that used to read in a few values into my program. However, when I run the program (without any compiler errors) The file does not get opened. It is saved in the same folder as the program so there should be no problem. Any clue why it is happening?
Oh, and just to show I am not having some error in the code, here is the relevant lines of code:
#include <iostream>
#include <fstream>
#include <cstdlib>
ifstream inventoryFile;
inventoryFile.open("inventory.in");
if (!inventoryFile) {
cerr << "File inventory.in could not be opened" << endl;
return 1;
}
int num_receipts;
int
salesman1_total = 0,
salesman2_total = 0;
int price, cost;
int initial_stock_on_hand;
inventoryFile >> initial_stock_on_hand;
inventoryFile >> price;
inventoryFile >> cost;
inventoryFile.close();