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();
}

Loops allow you to the same thing over and over again.
Arrays contain information of a similar type.
Using a strategy that combines those two topics should allow you to do what you want.

Thank u for ur reply.
But can u please explain me more clearly with an example pls.

//Declare vector (a vector is similar to an array) of STL string objects 
vector<string> myStrings;

//initialize array elements to something meaningful
myStrings[0] = "Hello";
myStrings[1] = " World";

//use a loop and the array to do something.
//in this case print the contents of the array to the screen
for(int i = 0; i < 2; ++i)
{
  cout << "myStrings[i];
}


//to use an array of C style strings.
//declare a static array of two strings that can hold up to ten char each
char myStrings[2][10];
//initialize the array using strcpy
strcpy(myStrings[0], "Hello");
strcpy(myStrings[1], " World");
//use as above
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.