- #1
americanforest
- 223
- 0
Hi everybody. I'm relatively new to C++ and am having an issue. What I need to do is take in several files and then do some data processing in each of them separately. I've tried to do this several ways and nothing has worked so far. Below is my last attempt.
Basically, each file is characterized not only by it's name but also by some information that the user has to give me. That's why I made a struct which holds info and the ifstream for each file. Then I decided to make an array of those to hold all the files. Can someone tell what is wrong with my code and how to fix it?
Basically, each file is characterized not only by it's name but also by some information that the user has to give me. That's why I made a struct which holds info and the ifstream for each file. Then I decided to make an array of those to hold all the files. Can someone tell what is wrong with my code and how to fix it?
Code:
using namespace std;
#include <string>
#include <iostream>
struct inputstream
{
ifstream input;
//other data
};
int main()
{
char bufferin[SIZE];
int nofiles;
cout<<"How many input files will you be using? ";
cin>>nofiles;
inputstream inFiles[nofiles];
for(int i=1;i<=nofiles;i++)
{
cout<<"Please Print File: ";
cin>>bufferin;
//ask user for more info about file and put into inFiles[i]
inFiles[i].input.open(bufferin);
}
}