I am looking up file names. The code is not complete here,
When I compile it there are no errors, but when I run it,
1. It does find the files and prints the fName4 value.
2. It does not print the fName7 value.
What am I doing wrong?
How do I get the value into fName7[i1]?
How do I get it back out?
The problem is not in finding the files,
the problem is in:
strcpy(fName7[i1], fName4)
The end program will have the cout lines removed, these are here just to test what is happening.
When I cout << fName4, it displays the good names: enc_ref.000, etc.
When I cout << fName7[i1] all I get is the surrounding text.
I need an indexable array of valid file names to display (later in the program) for the user to make a choice. I also will be making changes within the base name itself as this program is further developed.
I do not understand the push_back thing and wonder how this is indexable?
I will have to do some study on this vector thing to see if it will do my job for me.
When I first learned programming (Fortran) more than 40 years ago, it was always considered important to have your code written simply so the poor guy who had to look at your code after you could easily understand it. I have always thought in simple terms since, that is one reason I used the inelegant method to increment the file extension.
I will clean up the code prior to final compilation.
/* strcpy (fName4, fName7[i1]); // for test purposes only
if (f7.good()) cout << "\n Found file: " << fName4; // test purpose only */
if (f7.good()) i1++;
f7.close();
ext1[2]++; // increment file extension
if (ext1[2] > '9')
{ ext1[2] = '0';
ext1[1]++;
if (ext1[1] > '9')
{ ext1[1] = '0';
ext1[0]++;
if (ext1[0] > '9') done1 = true;
}
} // end file extension
if (i1 >= 99) done1 = true;
} // end while
I apreciate the response, but I still have two problems:
1. How do I properly post code segments?
2. I need a simple way to display fName7[i1] as it does not show with cout <<