// The number of ifstream userInfoFile[number] increases or decreases.
// Is there a way to dynamically make that part into a variable arrangement...?
// The number in the 'number' part is equal to userIDList.size().
// I thought I could use it as a variable
// I'm asking because I'm curious about how to enter a constant statically or set it dynamically through a specific method.
void FileManage::loadUserInfoFile() {
string tempID, tempEmail, tempAuth;
ifstream userInfoFile[5]; // Make it a dynamic array
try {
for (size_t i = 0; i < userIDList.size(); i++) {
openFileToRead(userInfoFile[i], (userIDList[i] + ".dat").c_str());
while (userInfoFile[i] >> tempID >> tempEmail >> tempAuth) {
insert email into userEmailList.push_back(tempEmail); // userEmailList vector
}
}
}
catch (string err) {
cerr << err << endl;
exit(EXIT_FAILURE);
}
for (size_t i = 0; i < userIDList.size(); i++) {
userInfoFile[i].close();
}
}
Write vector
vector userInfoFile
© 2024 OneMinuteCode. All rights reserved.