Read Files

Looking for help on this assignment cause i'm new to c++. Can anyone help me out with figuring this out? how to read multiples files with void prodecure? i'm getting confused in ifstream part. thanks for your help and i'm sorry for my broken eng

#include <bits/stdc++.h>
using namespace std;

void readFile(string file_name) {
string line;
ifstream myfile;

if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line << '\n';

}
myfile.close();

}

else
{
cout << "This file can't be opened";
}
}

int main () {
string file1 = "a.txt";
string file2 = "b.txt";
string file3 = "c.txt";
readFile(file1);
readFile(file2);
readFile(file3);
}
Topic archived. No new replies allowed.