I am writing a program that will have .dat files within a folder. The user will input the folder, and there should be a few .dat files within. How do I open up the files to read them into an array?! Please respond ASAP!! Thank you in advance for your help.
*NOTE: Use the most basic C++ you can; I am a beginner! Thanks! The entire getDir() was given to us to complete the assignment, I didn't write that!*
const int MAX_SIZE = 31;
int getDir(string dir, stringVector &files);
int main()
{
ifstream in_file;
ofstream out_file;
int i=0, array[MAX_SIZE], next;
float average_temp, maximum_temp;
int start;
string dir, intro;
intro = "C://*/*/*/*/*/*/Homework 06";
cout << "Enter directory with files available for use: "; cin >> dir;
cout << endl << intro + dir << endl;
stringVector files = stringVector();
getDir (dir, files);
for (unsigned int i = 0; i < files.size(); i++)
{
cout << files[i] << endl;
in_file.open(files[i].c_str());
while (in_file >> next) {
array[i] = next;
i++;
}
for (int i = 0; i < MAX_SIZE; i {
cout << array[i] << " ";
}
}
in_file.close();
out_file.close();
cin >> start;
return 0;
}
int getDir (string dir, stringVector &files)
{
DIR *dp;
struct dirent *dirp;