I want to be able to have this program open any/all text file/files that are in the same folder that the program resides in. Here is what I have thus far,
int main () {
cout << "This is what the file contained:\n";
char buffer[256];
ifstream fileName ("example.txt");
if (! fileName.is_open())
{ cout << "Error opening file"; exit (1); }
while (! fileName.eof() )
{
fileName.getline (buffer,100);
cout << "\n";
cout << buffer << endl;
}
int a;
cin >> a;
return 0;
}
it only opens one specific file ATM though. Could someone help edit this so that it opens any and all text files in its folder? TY in advance.
int main () {
cout << "This is what the file contained:\n";
char buffer[256];
ifstream fileName ("example.txt");
if (! fileName.is_open())
{ cout << "Error opening file"; exit (1); }
while (! fileName.eof() )
{
fileName.getline (buffer,100);
cout << "\n";
cout << buffer << endl;
}
int a;
cin >> a;
return 0;
}
it only opens one specific file ATM though. Could someone help edit this so that it opens any and all text files in its folder? TY in advance.