Search:
Forum
General C++ Programming
Read Files
Read Files
Oct 30, 2021 at 4:11pm UTC
masninoeh
(4)
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);
}
Oct 30, 2021 at 4:46pm UTC
salem c
(3700)
Three times
https://www.cplusplus.com/forum/beginner/280676/
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs