My best guess is that it's the following code that's causing the problem:
inFile >> Inventory.cost >> Inventory.price;
inFile.getline(Inventory.description, DESC_SIZE);
If there is a newline left after the input going into Inventory.price
, it will disrupt the following getline()
statement, as it stops when it reaches a newline character. You'll have to ignore it with ignore()
:
inFile >> Inventory.cost >> Inventory.price;
inFile.ignore(); // <==
inFile.getline(Inventory.description, DESC_SIZE);