Reading Multiple text files

Hi,
I want to know how to read multiple text files in this program...
I have 5 text files(order1,order2,...order5)
Can anyone pls help me with this?
I use DevC++.

#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<windows.h>
using namespace std;

class{
public:
void menu()
{
ifstream menu;
menu.open("menu.txt");
string STRING;
string inFile_contents;
string previousLine="";
while(!menu.eof())
{
getline(menu,STRING); // Saves the line in STRING.
if (STRING != previousLine)
{
previousLine=STRING;
cout<<STRING<<endl; // Prints our STRING.
}
}
menu.close();
}

void view_order()
{
ifstream order;
order.open("order.txt");
string STRING;
string inFile_contents;
string previousLine="";
while(!order.eof())
{
getline(order,STRING);
if (STRING != previousLine)
{
previousLine=STRING;
cout<<STRING<<endl;
}
}
order.close();
}
}c;

int main()
{
c.menu();
c.view_order();
getch();
}
Last edited on
http://www.cplusplus.com/articles/z13hAqkS/

You read multiple files the same way you do a single file.

1
2
3
4
5
ifstream order1;
ifstream order2;
ifstream order3;
ifstream order4;
ifstream order5;
Last edited on
Thank You SamuelAdams
i tried as u told and it is working
Hey I also have another problem can you pls help me with that.
I another question which I have posted "Reading contents And Calculating" in this same board.
Can pls go through it and help me out??
Thank You
Topic archived. No new replies allowed.