Hello there!
So I have an assignment where I am given a text file with customer information that I need to convert into a "label" format. The original file has caret (^) symbols marking the different lines to be organized.
I have the input totally finished, the only thing I'm stuck on is how to copy the data being stored from the input into a new user-declared text file?
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
using namespace std;
bool inputData(ifstream& inData);
void outputData(ofstream& outData);
int main()
{
ifstream inData;
ofstream outData;
inputData(inData);
inData.close();
outputData(outData);
system("pause");
return EXIT_SUCCESS;
}
bool inputData(ifstream& inData)
{
string inFileName;
bool done = false;
while(!done)
{
cout << "Enter input file name: ";
getline(cin, inFileName);
inData.open(inFileName.c_str());
if(inData.is_open() && inData.good())
{
cout << "Data Loaded." << endl;
done = true;
}
else
{
cout << "Bad File..." << endl;
inData.clear();
}
}
string custName;
string custAddress;
string custCity;
string custState;
string custZip;
while(!inData.eof())
{
getline(inData, custName, '^');
getline(inData, custAddress, '^');
getline(inData, custCity, '^');
getline(inData, custState, '^');
getline(inData, custZip);
}
}
void outputData(ofstream& outData)
{
string outFileName;
cout << "\nEnter output file name: ";
getline(cin, outFileName);
outData.open(outFileName.c_str());
}
//if(outData.is_open())
//{
//getline(outData,
Thanks in advance!