谁能告诉我为什么对以下变量所做的更改没有被拉到 main 中?
我对此很陌生,所以请保持简单。
如果您需要更多我的代码,请告诉我:D
void BannedWordsArrayCreate (string filePathInBanned, vector<string> bannedWords, vector<int> bannedWordsCount, vector<int> containsBannedWordsCount ) {
cout << "Please enter the file path for the banned word list. (no extension.): " << endl; //User enters file name
cout << "E.g. C:\\Users\\John\\banned" << endl;
cin >> filePathInBanned;
filePathInBanned += ".txt"; //Takes User defined file name and adds .txt
ifstream inFile;
inFile.open(filePathInBanned,ios::in); //opens file
if (!inFile) //if file cannot be opened: exits function.
{
cerr << "Can't open input file." << filePathInBanned << endl;
exit(1);
}
else if (inFile.is_open()) //if file opens: puts file into vector.
{
string bw = "nothing"; //temporary string used to signal end of file.
while(!inFile.eof() && bw != "")
{
inFile >> bw;
if (bw != "")
{
bannedWords.push_back(bw);
}
}
}
inFile.close();
cout << endl << "Done!" << endl << endl;
for(int i = 0; i < bannedWords.size(); i++)
{
bannedWordsCount.push_back(0);
containsBannedWordsCount.push_back(0);
}
}