I have a project that requires me to output the data from 2 files. Put them into their own arrays. Calculate the data from 1 of the files into a function. Then output the functions into a whole new file. This is what I have so far and right now I'm trying to figure out how to output the function output into a new file. When I try now, I get outputs in the file like "NULL NULL". I also have to align the data in columns.
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
char states();
char stData();
char states()
{
const int SIZE = 0;
ifstream myfile("csc114_states.txt");
string line, myArray[SIZE];
if (myfile.is_open())
{
for (int i = 1; i < SIZE; i++)
{
myfile >> myArray[i];
cout << myArray[i];
cout << endl;
}
myfile.close();
}
myfile.open("csc114_states.txt");
if (myfile.is_open())
{
string tp;
while (getline(myfile, tp))
{
cout << tp << "\n";
}
myfile.close();
}
else
{
cout << "Unable to open file." << endl;
return 0;
}
return 0;
}
char stDATA()
{
const int size1 = 0;
const int size2 = 0;
string myArray2[size1][size2], line;
ifstream myfile2("csc114_data.txt");
if (myfile2.is_open())
{
for (int i = 0; i < size1; i++)
{
for (int j = 0; j < size2; j++)
{
myfile2 >> myArray2[i][j];
cout << myArray2[i][j];
cout << endl;
}
}
myfile2.close();
}
myfile2.open("csc114_data.txt");
if (myfile2.is_open())
{
string tp2;
while (getline(myfile2, tp2))
{
cout << setw(0) << tp2 << "\n";
}
myfile2.close();
}
else
{
cout << "Unable to open file." << endl;
return 0;
}
return 0;
}
int main()
{
ofstream bigFile("csc114_output.txt");
if (bigFile.is_open())
{
bigFile << states() << stDATA();
bigFile.close();
}
else
{
cout << "Unable to open files.";
}
return 0;
}