I want to read the string in 4 files as the cose show, the problem is that the code read the data from the first file only ?!!this is the code ....I dont know what is the problem
Code:
ifstream inFile1;
char *p;
p = new char[500];
ofstream Result;
Result.open("Result.txt");
for(i=1;i<5;++i)
{
//Inter the Patterns file
cout<<"Enter patterns file name.\n";
cin>>pattern;
inFile1.open(pattern.c_str());
if ( !inFile1 )
{
cout<<"Unable to open file. Enter a different name: ";
inFile1.clear();
cin >> pattern;
inFile1.open(pattern.c_str());
}
//Define files for patterns after classification
while(!inFile1.eof())
{
getline(inFile1, line);
strcpy_s(p, 500, line.c_str());
cout<<strlen(p)<<"\n";
}
}
cout<<"endfile\n";
inFile1.close();
}