Exzample code...
const int SIZEOFFILENAMES = 100;
string fileNames[SIZEOFFILENAMES];
int main () {
string inFilePath;
cout << "Specify the file path:" << endl;
cin >> inFilePath;
ifstream inFile;
// open in binary
inFile.open(inFilePath.c_str(), ios::binary);
inFile.seekg(0, ios_base::end);
int fileLen = inFile.tellg();
inFile.seekg(0, ios_base::beg);
char charArr[10000];
inFile.read(charArr, fileLen);
inFile.close();
inFile.clear(ios_base::goodbit);
Pesudo code would be.
Check filename Array element size.
append inFilePath to Next Free element.
}
Here's a trivial minimal example for adding the inputted filepath to your vector of filenames:
// ...
#include <vector>
#include <string>
std::vector<std::string> fileNames;
int main ()
{
std::string inFilePath;
std::cout << "Specify the file path:" << std::endl;
std::cin >> inFilePath;
filenames.push_back(inFilePath);
// do other stuff
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.