I'm downloading a a series of filenames and need to load these files into a matrix. When I request a new file name from my matrix of strings, I show an error that the filename has been previously declared (even though I closed it).
I've attached an example with two file reads. I'd like to sequentially read files in with the same string "filename" (myfile in the example below) but changing the content of "filename" to different file titles.
Thanks - it compiles, but will not output the second file. After opening the second file, it does not appear to read it (I tested to see that the file existed in my program).
I corrected the file tests (as above) but still have no data download from the second file opened.
The check myfile.open() returns true, while the check myfile.good() returns false. The program recogonizes the file [(!myfile.is_open()) returns false].
So, I'm still getting no file contents read in on the second file.
if (!myfile.is_open())
{
cout<<"File Not Found"<<endl;
return -1;
}
seg="";
while(getline(myfile, seg, '\n'))
{
cout<<seg<<endl;
}
myfile.close();
return 0;
ps Austin J(289): I believe looping with getline reduces the program by a step and also returns false after the last value. Looping on eof() adds a step and returns an extra value of null at the end which needs to be discarded or disregarded.