system("PAUSE");
return EXIT_SUCCESS;
}
void get_file (char in_file, char out_file, ifstream fin, ofstream fout)
{
cout << "What is the name of the file containing data to be analyzed?"
cin >> in_file;
fin.open(in_file);
if (fin.fail())
{
cout << "Input file failed.\n.";
exit(1);
}
cout << "What is the name of the file where you would like to store data? \n"
cin >> out_file;
fout.open(out_file);
if (fout.fail())
{
cout << "imput file failed.\n.";
exit(1);
}
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
// this goes first before referencing classes, objects and functions inside the namespace
usingnamespace std;
// you forgot char*
// also pass ifstream and ofstream by reference or by pointer
// why?? because its copy constructor is private (can't be copied)
void get_file(char* in_file, char* out_file, ifstream& fin, ofstream& fout);
/* to get, open, and test the files for input and output data.*/
int main(int argc, char *argv[])
{
char in_file[40], out_file[40];
ifstream fin;
ofstream fout;
get_file (in_file, out_file, fin, fout);
system("PAUSE");
return EXIT_SUCCESS;
}
void get_file (char* in_file, char* out_file, ifstream& fin, ofstream& fout)
{
cout << "What is the name of the file containing data to be analyzed?"; // forgot semicolon
cin >> in_file;
fin.open(in_file);
if (fin.fail())
{
cout << "Input file failed.\n.";
exit(1);
}
cout << "What is the name of the file where you would like to store data? \n"; // forgot semicolon
cin >> out_file;
fout.open(out_file);
if (fout.fail())
{
cout << "imput file failed.\n.";
exit(1);
}
}