Question: So I'm coding in C++ and I'm attempting to alter my current code below to align with the order my .txt file is currently in.
So I'm coding in C++ and I'm attempting to alter my current code below to align with the order my .txt file is currently in. Here is the order of my .txt file:
Manufacturer
Processor
RAM
Disk Size
Cost
Location
Date Acquired
Asset Tag
I am attempting to re-arrange it to output the following order:

My current C++ code:
#include
struct Date{ short day; short month; int year; };
struct Inventory{ string manufacturer; string processor; int ram; int disk_size; double cost; string location; Date date_acquired; string asset_tag; };
Inventory read_record(ifstream &inFile);
void format_record(const Inventory &inv);
int main(){ ifstream inFile; inFile.open("input.txt"); if(inFile.fail()){ cout
Inventory record;
while(!inFile.eof()){ record = read_record(inFile); format_record(record); }
inFile.close();
return 0; }
Inventory read_record(ifstream &inFile){ Inventory rec; inFile >> rec.asset_tag >> rec.date_acquired.month >> rec.date_acquired.day >> rec.date_acquired.year >> rec.cost; getline(inFile, rec.location); getline(inFile, rec.location); getline(inFile, rec.manufacturer); getline(inFile, rec.processor); inFile >> rec.ram >> rec.disk_size; return rec; }
void format_record(const Inventory &inv){ cout Asset Tag: 20191231-PC-021 03/24/2007 Acquired: $1087.99 Cost: 256 Location: Manufacturer: Dell Core i7 8700 (3.2 GHz) CPU: RAM: 16 GB Disk: 256 GB Asset Tag: 20191215-PC-045 08/01/2010 Acquired: $459.00 Cost: Location: 128 ompaq Ryzen 2400GE (3.20 GHz) 8 GB Manufacturer: CPU: RAM: Disk: 1024 GB
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
