correct.. actually i thought first create a program which can read one file.. now we can go to reading a directry.
infact your previous program which was reading a directry is correct..
lets say:
Ok, thats what I expected, but this is what I have:
for (unsigned int i = 0; i < files.size(); i++)
{
ifstream indiv_file;
int arr[MAX_SIZE];
indiv_file.open("intro+dir");
indiv_file.open((dir + files[i]).c_str());
cout<< dir+files[i]<<endl;
with line 2 there, i was told that is how I open the files. can you just write out my main() function with the directory search added? then I can ask questions why things are a certain way rather than what I have... thanks!!
//collect all the files first in a some directory.
vector<string> file_list;
string dir = "/home/satchmo05";
if((dp = opendir(dir.c_str())) == NULL)
{
cout << "Error(" << errno << ") opening " << dir << endl;
return errno;
}
while ((dirp = readdir(dp)) != NULL)
{
file_list.push_back(string(dirp->d_name));
}
closedir(dp);
//you have collected all the file names in the directory, open each file,read it and then next.
int fsize = file_list.size();
for(int i = 0; i < fsize; i++)
{
ifstream indiv_file;
indiv_file.open(file_list[i].c_str());
if(indiv_file.fail())
return 0;
int next;
int arr[MAX_SIZE];
int i = 0;
while (indiv_file >> next)
{
arr[i] = next;
i++;
if(i == MAX_SIZE)
break;
}
for (int j = 0; j < i; j++)
{
cout << arr[j] << endl;
}
indiv_file.close();
}
understand this, fine tune this program and thats it.